2

我被詹金斯的掌舵安装困住了

:(

请帮忙!

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

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

使用通用存储类.yaml:

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

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

$ kubectl apply -f jenkins-pvc.yaml

使用 jenkins-pvc.yaml:

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

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

$ 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 安装 jenkins 时:

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

我得到这个输出:

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

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

为什么helm没有使用“existingClaim”

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

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

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

kubectl get pvc --all-namespaces
NAMESPACE         NAME               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-project   jenkins            Bound    pvc-a9caa3ba-7cf1-11e9-a90f-161c7e8a0754   8Gi        RWO            gp2            6m11s
jenkins-project   jenkins-pvc        Bound    pvc-a173294f-7cea-11e9-a90f-161c7e8a0754   20Gi       RWO            gp2            56m

我觉得我很接近但缺少一些基本的东西。有任何想法吗?

4

1 回答 1

4

因此,根据 Matthew L Daniel 的评论,我运行helm repo update然后重新运行了 helm install 命令。这次它没有重新创建 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
于 2019-05-23T05:26:51.370 回答