我如何使用现有的PVC掌舵马stable /詹金斯

时间:2019-05-23 00:46:50

标签: jenkins kubernetes kubernetes-helm kubernetes-pvc

我被困在詹金斯的头盔上

:(

请帮助!

我通过以下方式预定义了存储类:

<a>

与generic-storage-class.yaml:

$ kubectl apply -f generic-storage-class.yaml 

然后我通过以下方式定义PVC:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: generic
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  zones: us-east-1a, us-east-1b, us-east-1c
  fsType: ext4

与jenkins-pvc.yaml:

$ kubectl apply -f jenkins-pvc.yaml

然后我可以看到PVC进入BOUND状态:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: jenkins-project
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

但是当我尝试通过以下方式安装Helm安装詹金斯时:

$ kubectl get pvc --all-namespaces
NAMESPACE         NAME               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-project   jenkins-pvc        Bound    pvc-a173294f-7cea-11e9-a90f-161c7e8a0754   20Gi       RWO            gp2            27m

我得到以下输出:

$ helm install --name jenkins \
--set persistence.existingClaim=jenkins-pvc \
stable/jenkins --namespace jenkins-project

我看到掌舵创建了一个名为jenkins的新PersistentVolumeClaim。

掌舵者为何不使用“ existingClaim”

我认为这是jenkins版本的唯一头盔值

NAME:   jenkins
LAST DEPLOYED: Wed May 22 17:07:44 2019
NAMESPACE: jenkins-project
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME           DATA  AGE
jenkins        5     0s
jenkins-tests  1     0s

==> v1/Deployment
NAME     READY  UP-TO-DATE  AVAILABLE  AGE
jenkins  0/1    1           0          0s

==> v1/PersistentVolumeClaim
NAME     STATUS   VOLUME  CAPACITY  ACCESS MODES  STORAGECLASS  AGE
jenkins  Pending  gp2     0s

==> v1/Pod(related)
NAME                      READY  STATUS   RESTARTS  AGE
jenkins-6c9f9f5478-czdbh  0/1    Pending  0         0s

==> v1/Secret
NAME     TYPE    DATA  AGE
jenkins  Opaque  2     0s

==> v1/Service
NAME           TYPE          CLUSTER-IP      EXTERNAL-IP  PORT(S)         AGE
jenkins        LoadBalancer  10.100.200.27   <pending>    8080:31157/TCP  0s
jenkins-agent  ClusterIP     10.100.221.179  <none>       50000/TCP       0s


NOTES:
1. Get your 'admin' user password by running:
  printf $(kubectl get secret --namespace jenkins-project jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo
2. Get the Jenkins URL to visit by running these commands in the same shell:
  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get svc --namespace jenkins-project -w jenkins'
  export SERVICE_IP=$(kubectl get svc --namespace jenkins-project jenkins --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
  echo http://$SERVICE_IP:8080/login

3. Login with the password from step 1 and the username: admin


For more information on running Jenkins on Kubernetes, visit:
https://cloud.google.com/solutions/jenkins-on-container-engine

实际上,它只是制作了自己的PVC而不是使用预先创建的PVC。

$ helm get values jenkins
persistence:
  existingClaim: jenkins-pvc

我感觉自己很接近,但是缺少一些基本知识。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

因此,根据Matthew L Daniel的评论,我运行了helm repo update,然后重新运行了头盔安装命令。这次它没有重新创建PVC,而是使用了预制的PVC。

我以前的詹金斯图表版本是“ jenkins-0.35.0”

对于想知道部署是什么样的人:

Name:               jenkins
Namespace:          jenkins-project
CreationTimestamp:  Wed, 22 May 2019 22:03:33 -0700
Labels:             app.kubernetes.io/component=jenkins-master
                    app.kubernetes.io/instance=jenkins
                    app.kubernetes.io/managed-by=Tiller
                    app.kubernetes.io/name=jenkins
                    helm.sh/chart=jenkins-1.1.21
Annotations:        deployment.kubernetes.io/revision: 1
Selector:           app.kubernetes.io/component=jenkins-master,app.kubernetes.io/instance=jenkins
Replicas:           1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:       Recreate
MinReadySeconds:    0
Pod Template:
  Labels:           app.kubernetes.io/component=jenkins-master
                    app.kubernetes.io/instance=jenkins
                    app.kubernetes.io/managed-by=Tiller
                    app.kubernetes.io/name=jenkins
                    helm.sh/chart=jenkins-1.1.21
  Annotations:      checksum/config: 867177d7ed5c3002201650b63dad00de7eb1e45a6622e543b80fae1f674a99cb
  Service Account:  jenkins
  Init Containers:
   copy-default-config:
    Image:      jenkins/jenkins:lts
    Port:       <none>
    Host Port:  <none>
    Command:
      sh
      /var/jenkins_config/apply_config.sh
    Limits:
      cpu:     2
      memory:  4Gi
    Requests:
      cpu:     50m
      memory:  256Mi
    Environment:
      ADMIN_PASSWORD:  <set to the key 'jenkins-admin-password' in secret 'jenkins'>  Optional: false
      ADMIN_USER:      <set to the key 'jenkins-admin-user' in secret 'jenkins'>      Optional: false
    Mounts:
      /tmp from tmp (rw)
      /usr/share/jenkins/ref/plugins from plugins (rw)
      /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
      /var/jenkins_config from jenkins-config (rw)
      /var/jenkins_home from jenkins-home (rw)
      /var/jenkins_plugins from plugin-dir (rw)
  Containers:
   jenkins:
    Image:       jenkins/jenkins:lts
    Ports:       8080/TCP, 50000/TCP
    Host Ports:  0/TCP, 0/TCP
    Args:
      --argumentsRealm.passwd.$(ADMIN_USER)=$(ADMIN_PASSWORD)
      --argumentsRealm.roles.$(ADMIN_USER)=admin
    Limits:
      cpu:     2
      memory:  4Gi
    Requests:
      cpu:      50m
      memory:   256Mi
    Liveness:   http-get http://:http/login delay=90s timeout=5s period=10s #success=1 #failure=5
    Readiness:  http-get http://:http/login delay=60s timeout=5s period=10s #success=1 #failure=3
    Environment:
      JAVA_OPTS:
      JENKINS_OPTS:
      JENKINS_SLAVE_AGENT_PORT:  50000
      ADMIN_PASSWORD:            <set to the key 'jenkins-admin-password' in secret 'jenkins'>  Optional: false
      ADMIN_USER:                <set to the key 'jenkins-admin-user' in secret 'jenkins'>      Optional: false
    Mounts:
      /tmp from tmp (rw)
      /usr/share/jenkins/ref/plugins/ from plugin-dir (rw)
      /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
      /var/jenkins_config from jenkins-config (ro)
      /var/jenkins_home from jenkins-home (rw)
  Volumes:
   plugins:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   tmp:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   jenkins-config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      jenkins
    Optional:  false
   plugin-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   secrets-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   jenkins-home:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  jenkins-pvc
    ReadOnly:   false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  jenkins-86dcf94679 (1/1 replicas created)
NewReplicaSet:   <none>
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  42s   deployment-controller  Scaled up replica set jenkins-86dcf94679 to 1