1. Install the helm package
https://github.com/helm/helm/blob/master/LICENSE
2. helm to configure the environment variables
3. Use the helm installed on the premise that kubectl
4. Use the command to view the cluster configuration kubectl
Normal communication (cluster inaccessible if prompted, according to Bowen settings: cluster is indicated as shown in https://www.cnblogs.com/miaoying/p/11193621.html )
$ kubectl cluster-info Kubernetes master is running at https://192.168.1.164:6443 KubeDNS is running at https://192.168.1.164:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy kubernetes-dashboard is running at https://192.168.1.164:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:https/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
5. Review k8s the client, server version are the same at both ends
$ kubectl version Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"} Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:32:14Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
At first I was a client-side version of 1.10.3, server-side is 1.15.0, resulting throw an exception has been used locally helm install packages, such as:
Error: release config failed: Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment.Status: v1beta1.DeploymentStatus.Conditions: []v1beta1.DeploymentCondition: v1beta1.DeploymentCondition.Status: ReadString: expects " or n, but found t, error found in #10 byte of ...|"status":true,"type"|..., bigger context ...|ty","reason":"MinimumReplicasAvailable","status":true,"type":"Available"}],"observedGeneration":5,"r|...
The reason is inconsistent with the client-side version of the server-side, leading to the understanding of the two ends of the profile is not the same, and some configuration attributes low version is not supported.
6. The upgraded version of client, server-side to the same: 1.15.0
The download version of the client end
https://dl.k8s.io/v1.15.0/kubernetes-client-windows-amd64.tar.gz
View kubectl position
$ which kubectl /c/Program Files/Docker/Docker/Resources/bin/kubectl
Kubectl found in the docker (due to my kubectl tool that comes with the installation docker for windows, built-in docker inside)
To make each time kubectl use, it can be used 1.15.0 version, the need for kubectl reconfigure the environment variable, and I is placed directly inside the Path system environment variable, and will move to its position on the front
Another open a terminal position kubectl view again, as follows:
$ which kubectl /f/kubernetes/install-1.15.0/kubectl
View kubectl version information (version information at this time is a uniform)
$ kubectl version Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"windows/amd64"} Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:32:14Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
7. Review the current context kubernetes
$ Kubectl config current- Context
kubernetes -admin @ kubernetes
8. Initialization and mounted tiller helm
helm init
Helm default due to storage.googleapis.com pull mirroring, if the machine you are currently executing can not access the domain name, then you can use the following command to install
helm init --client-only --stable-repo-url https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/ helm repo add incubator https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ helm repo update
Create a server
helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.2 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
View tiller
$ kubectl -n kube-system get pods|grep tiller tiller-deploy-6bb85c7cb7-jhr65 1/1 Running 1 34h
9. Construction of a chart
I build directory structure chart is as follows:
| - dateway | ---- Templates # [optional] deployment template file directory, using values from the value of the template and the tiller values.yaml provided | ----- | - deployment.yaml | ---- Charts.yaml # yaml file, the basic information used to describe the chart, including the name of the version, etc. | ---- values.yaml # chart of the default configuration file
Service configuration file charts (note yaml file format), by pulling pre-existing deployment project profile: for example, I was pulling curl configuration file as a sample kubectl get Deployment curl -o yaml> curl.yaml
(Yaml format is legal, it can be tested by http://www.bejson.com/validators/yaml_editor/)
deployment.yaml
apiVersion: extensions/v1beta1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" creationTimestamp: 2019-07-15T09:36:17Z generation: 1 labels: app: gateway name: gateway namespace: rubikt resourceVersion: "1544" selfLink: /apis/extensions/v1beta1/namespaces/rubikt/deployments/gateway uid: a0ca862b-4a12-11e9-80d3-0050569b47c5 spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: gateway strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: gateway spec: containers: - image: 192.168.2.50/health/gateway:1.5.1-SNAPSHOT ports: - {containerPort: 8080, protocol: TCP} env: - {name: JAVA_OPTS, value: '-Denv=dev -Ddev_meta=http://apollo.dev.zwjk.com -Dapp.id=health-gateway -server -Xmx768m'} - {name: CONSUL_URL, value: 10.109.36.166} - {name: CONSUL_HOST, value: 10.100.39.12} - {name: CONSUL_PORT, value: '8500'} terminationMessagePath: /dev/termination-log name: gateway resources: limits: cpu: 200m memory: 768Mi requests: cpu: 50m memory: 512Mi dnsPolicy: ClusterFirst restartPolicy: Always securityContext: {} terminationGracePeriodSeconds: 30 imagePullPolicy: Always imagePullSecrets: - {name: ccr.ccs.tencentyun.com.key} status: availableReplicas: 1 conditions: - lastTransitionTime: 2019-07-15T09:36:17Z lastUpdateTime: 2019-07-15T09:43:17Z message: ReplicaSet "gateway-6bf6db5c4f" has successfully progressed. reason: NewReplicaSetAvailable status: "True" type: Progressing - lastTransitionTime: 2019-07-15T09:43:59Z lastUpdateTime: 2019-07-15T09:43:59Z message: Deployment has minimum availability. reason: MinimumReplicasAvailable status: "True" type: Available observedGeneration: 1 readyReplicas: 1 replicas: 1 updatedReplicas: 1
service.yaml
kind: Service apiVersion: v1 metadata: name: gateway namespace: rubikt selfLink: /api/v1/namespaces/rubikt/services/gateway uid: 43fd6588-4a14-11e9-80d3-0050569b47c5 resourceVersion: '103503' labels: {app: gateway} spec: ports: - {protocol: TCP, port: 8080, targetPort: 8080, nodePort: 30013} selector: {app: gateway} type: NodePort sessionAffinity: None status: loadBalancer: {}
Chart.yaml
name: gateway version: "v1.0" description: gateway
values.yaml
docker: registry: 192.168.2.50/health/gateway:1.5.1-SNAPSHOT pullPolicy: Always core: replicas: 1 config: version: "v1.0"
10. Use command to verify the validity of the configuration chart
This output variable contains the template configuration files and final rendered yaml
(When kubernetes deploying applications, actually rendered the templates yaml kubernetes final format which can be recognized)
$ helm install --dry-run --debug gateway [debug] Created tunnel using local port: '56560' [debug] SERVER: "127.0.0.1:56560" [debug] Original chart version: "" [debug] CHART PATH: D:\zhuojian-projects\rubik-T\k8s\gateway NAME: snug-hare REVISION: 1 RELEASED: Thu Jul 18 18:03:57 2019 CHART: gateway-v1.0 USER-SUPPLIED VALUES: {} COMPUTED VALUES: config: version: v1.0 core: replicas: 1 docker: pullPolicy: Always registry: 192.168.2.50/health/gateway:1.5.1-SNAPSHOT HOOKS: MANIFEST: --- # Source: gateway/templates/service.yaml kind: Service apiVersion: v1 metadata: name: gateway namespace: rubikt selfLink: /api/v1/namespaces/rubikt/services/gateway uid: 43fd6588-4a14-11e9-80d3-0050569b47c5 resourceVersion: '103503' labels: {app: gateway} spec: ports: - {protocol: TCP, port: 8080, targetPort: 8080, nodePort: 30013} selector: {app: gateway} type: NodePort sessionAffinity: None status: loadBalancer: {} --- # Source: gateway/templates/deployment.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" creationTimestamp: 2019-07-15T09:36:17Z generation: 1 labels: app: gateway name: gateway namespace: rubikt resourceVersion: "1544" selfLink: /apis/extensions/v1beta1/namespaces/rubikt/deployments/gateway uid: a0ca862b-4a12-11e9-80d3-0050569b47c5 spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: gateway strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: gateway spec: containers: - image: 192.168.2.50/health/gateway:1.5.1-SNAPSHOT ports: - {containerPort: 8080, protocol: TCP} env: - {name: JAVA_OPTS, value: '-Denv=dev -Ddev_meta=http://apollo.dev.zwjk.com -Dapp.id=health-gateway -server -Xmx768m'} - {name: CONSUL_URL, value: 10.109.36.166} - {name: CONSUL_HOST, value: 10.100.39.12} - {name: CONSUL_PORT, value: '8500'} terminationMessagePath: /dev/termination-log name: gateway resources: limits: cpu: 200m memory: 768Mi requests: cpu: 50m memory: 512Mi dnsPolicy: ClusterFirst restartPolicy: Always securityContext: {} terminationGracePeriodSeconds: 30 imagePullPolicy: Always imagePullSecrets: - {name: ccr.ccs.tencentyun.com.key} status: availableReplicas: 1 conditions: - lastTransitionTime: 2019-07-15T09:36:17Z lastUpdateTime: 2019-07-15T09:43:17Z message: ReplicaSet "gateway-6bf6db5c4f" has successfully progressed. reason: NewReplicaSetAvailable status: "True" type: Progressing - lastTransitionTime: 2019-07-15T09:43:59Z lastUpdateTime: 2019-07-15T09:43:59Z message: Deployment has minimum availability. reason: MinimumReplicasAvailable status: "True" type: Available observedGeneration: 1 readyReplicas: 1 replicas: 1 updatedReplicas: 1
11. Chart mounted to kubernetes
helm install -n gateway gateway
Now gateway has been deployed to the cluster, the native executable command to view examples
$ kubectl get pods --namespace rubikt NAME READY STATUS RESTARTS AGE gateway-86584799f-kvvsh 1/1 Running 0 31h
12. Review the deployment of release
$ helm list NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE gateway 5 Thu Jul 18 11:14:58 2019 DEPLOYED gateway-v1.0 default
The current release includes resources are: Service, Deployment, Secret, PersistentVolumeClaim
View Service:
$ kubectl get service --namespace rubikt NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE gateway NodePort 10.109.149.47 <none> 8080:30013/TCP 25h
View Deployment:
$ kubectl get Deployment --namespace rubikt NAME READY UP-TO-DATE AVAILABLE AGE gateway 1/1 1 1 47h
View Secret:
$ kubectl get Secret --namespace rubikt NAME TYPE DATA AGE default-token-687fw kubernetes.io/service-account-token 3 2d5h
View PersistentVolumeClaim:
$ kubectl get PersistentVolumeClaim --namespace rubikt
No resources found.
13. The configuration upgrade
After updating the configuration file, you can use the upgrade command to update (this application to do the upgrade)
$ helm upgrade config config --description config升级 --version 2.0 Release "config" has been upgraded. LAST DEPLOYED: Tue Jul 16 17:05:02 2019 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE config-6c7b9f6885-jkf6j 1/1 Running 0 3m55s config-fcf75984-vrd2f 0/1 ContainerCreating 0 0s ==> v1beta1/Deployment NAME READY UP-TO-DATE AVAILABLE AGE config 1/1 1 1 23m
Config can see the deployment has been upgraded to a version, revision = 2
$ helm list NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE config 2 Tue Jul 16 16:54:51 2019 DEPLOYED config-v1.0 default
14. version rollback
Rollback application versions, first use the helm history command to view the change history
$ helm history config REVISION UPDATED STATUS CHART DESCRIPTION 1 Tue Jul 16 16:41:10 2019 SUPERSEDED config-v1.0 Install complete 2 Tue Jul 16 16:54:51 2019 SUPERSEDED config-v1.0 Upgrade complete 3 Tue Jul 16 17:01:08 2019 SUPERSEDED config-v1.0 Rollback to 1 4 Tue Jul 16 17:05:02 2019 DEPLOYED config-v1.0 config升级
Reversion to roll back to version 2
$ helm rollback config 2 Rollback was a success.
Also: the problem after deployment to k8s, it may occur :( indicate the need to configure memory space)