From 9238e5c9cf7b726eb1004615ce208717af6eb75d Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Tue, 4 Dec 2018 02:43:54 +0300 Subject: [PATCH] helm packaging --- 01-pods/nginx-nodeselector.yaml | 2 +- 02-deployments/rollingupdate/nginx-dpl.yaml | 26 ++++++ 06-services/ReadMe.md | 5 ++ .../ingress/context/ingress-tls-nginx.yaml | 20 +++++ 06-services/intro/kuard-pod-svc-lb.yaml | 3 - 06-services/intro/kuard-pod-svc-np.yaml | 3 - 06-services/intro/kuard-pod-svc.yaml | 5 +- 08-storage/portability/02-gcpd-pv-pvc.yaml | 2 +- 09-crd/01-crd.yaml | 27 ++++++ .../01-helm/01-installation/Readme.md | 85 +++++++++++++++++++ 10 files changed, 166 insertions(+), 12 deletions(-) create mode 100644 02-deployments/rollingupdate/nginx-dpl.yaml create mode 100644 06-services/ingress/context/ingress-tls-nginx.yaml create mode 100644 09-crd/01-crd.yaml create mode 100644 10-ks8-packaging/01-helm/01-installation/Readme.md diff --git a/01-pods/nginx-nodeselector.yaml b/01-pods/nginx-nodeselector.yaml index 3eba389..462dec2 100644 --- a/01-pods/nginx-nodeselector.yaml +++ b/01-pods/nginx-nodeselector.yaml @@ -10,4 +10,4 @@ spec: image: nginx imagePullPolicy: IfNotPresent nodeSelector: - cpu: mukemmel + cpu: kotu diff --git a/02-deployments/rollingupdate/nginx-dpl.yaml b/02-deployments/rollingupdate/nginx-dpl.yaml new file mode 100644 index 0000000..ea557b3 --- /dev/null +++ b/02-deployments/rollingupdate/nginx-dpl.yaml @@ -0,0 +1,26 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: nginx-test +spec: + replicas: 5 + selector: + matchLabels: + service: http-server + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 50% + maxUnavailable: 1 + minReadySeconds: 5 + template: + metadata: + labels: + service: http-server + spec: + containers: + - name: nginx + image: nginx:1.7.9 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 80 diff --git a/06-services/ReadMe.md b/06-services/ReadMe.md index e69de29..e6e28cc 100644 --- a/06-services/ReadMe.md +++ b/06-services/ReadMe.md @@ -0,0 +1,5 @@ +```bash +#cluster-info +gcloud container clusters describe meetup --project=inspired-bus-194216 --zone=us-central1-c --format="json" | grep service +gcloud container clusters describe meetup --project=inspired-bus-194216 --zone=us-central1-c --format="json" | grep Ip +``` diff --git a/06-services/ingress/context/ingress-tls-nginx.yaml b/06-services/ingress/context/ingress-tls-nginx.yaml new file mode 100644 index 0000000..794eb28 --- /dev/null +++ b/06-services/ingress/context/ingress-tls-nginx.yaml @@ -0,0 +1,20 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: web-ingress + annotations: + kubernetes.io/ingress.class: nginx +spec: + rules: + - http: + paths: + - path: /v2/* + backend: + serviceName: web-v2 + servicePort: 8080 + - path: /v1/* + backend: + serviceName: web-v1 + servicePort: 8080 + tls: + - secretName: web-tls diff --git a/06-services/intro/kuard-pod-svc-lb.yaml b/06-services/intro/kuard-pod-svc-lb.yaml index 5d8185a..13a7025 100644 --- a/06-services/intro/kuard-pod-svc-lb.yaml +++ b/06-services/intro/kuard-pod-svc-lb.yaml @@ -3,8 +3,6 @@ kind: Service metadata: creationTimestamp: null labels: - internalVersion: 0.0.1 - name: kuard run: kuard name: kuard spec: @@ -14,7 +12,6 @@ spec: targetPort: 8080 selector: internalVersion: 0.0.1 - name: kuard run: kuard type: LoadBalancer status: diff --git a/06-services/intro/kuard-pod-svc-np.yaml b/06-services/intro/kuard-pod-svc-np.yaml index e7d846e..0a4226e 100644 --- a/06-services/intro/kuard-pod-svc-np.yaml +++ b/06-services/intro/kuard-pod-svc-np.yaml @@ -3,8 +3,6 @@ kind: Service metadata: creationTimestamp: null labels: - internalVersion: 0.0.1 - name: kuard run: kuard name: kuard spec: @@ -14,7 +12,6 @@ spec: targetPort: 8080 selector: internalVersion: 0.0.1 - name: kuard run: kuard type: NodePort status: diff --git a/06-services/intro/kuard-pod-svc.yaml b/06-services/intro/kuard-pod-svc.yaml index 9c694e1..0a4226e 100644 --- a/06-services/intro/kuard-pod-svc.yaml +++ b/06-services/intro/kuard-pod-svc.yaml @@ -3,8 +3,6 @@ kind: Service metadata: creationTimestamp: null labels: - internalVersion: 0.0.1 - name: kuard run: kuard name: kuard spec: @@ -14,8 +12,7 @@ spec: targetPort: 8080 selector: internalVersion: 0.0.1 - name: kuard run: kuard - type: ClusterIP + type: NodePort status: loadBalancer: {} diff --git a/08-storage/portability/02-gcpd-pv-pvc.yaml b/08-storage/portability/02-gcpd-pv-pvc.yaml index 0d957c5..271d92e 100644 --- a/08-storage/portability/02-gcpd-pv-pvc.yaml +++ b/08-storage/portability/02-gcpd-pv-pvc.yaml @@ -7,7 +7,7 @@ spec: storage: 10Gi accessModes: - ReadWriteOnce - gcePersistnetDisk: + gcePersistentDisk: pdName: meetup-disk fsType: ext4 diff --git a/09-crd/01-crd.yaml b/09-crd/01-crd.yaml new file mode 100644 index 0000000..942da19 --- /dev/null +++ b/09-crd/01-crd.yaml @@ -0,0 +1,27 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + # name must match the spec fields below, and be in the form: . + name: crontabs.stable.example.com +spec: + # group name to use for REST API: /apis// + group: stable.example.com + # list of versions supported by this CustomResourceDefinition + versions: + - name: v1 + # Each version can be enabled/disabled by Served flag. + served: true + # One and only one version must be marked as the storage version. + storage: true + # either Namespaced or Cluster + scope: Namespaced + names: + # plural name to be used in the URL: /apis/// + plural: crontabs + # singular name to be used as an alias on the CLI and for display + singular: crontab + # kind is normally the CamelCased singular type. Your resource manifests use this. + kind: CronTab + # shortNames allow shorter string to match your resource on the CLI + shortNames: + - ct diff --git a/10-ks8-packaging/01-helm/01-installation/Readme.md b/10-ks8-packaging/01-helm/01-installation/Readme.md new file mode 100644 index 0000000..354e39c --- /dev/null +++ b/10-ks8-packaging/01-helm/01-installation/Readme.md @@ -0,0 +1,85 @@ +#### Installation +```bash +kubectl create serviceaccount --namespace kube-system tiller +kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller +helm init --service-account tiller --upgrade +kubectl get deployment -n kube-system -o yaml tiller-deploy | grep serviceAccount +``` + +#### Helm uninstall from cluster +```bash +helm reset +kubectl get pods -n kube-system +``` + +#### Forget to create service account + +```bash +#https://github.com/fnproject/fn-helm/issues/21 +helm init +helm list +kubectl create serviceaccount --namespace kube-system tiller +kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller +kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' +helm --help +helm list --help +helm list +helm list -a +``` + +#### Stable Charts && Incubator Charts +```bash +helm search mysql +helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ +helm search cassandra +curl -XGET https://kubernetes-charts-incubator.storage.googleapis.com/ +``` + +open from Chrome https://console.cloud.google.com/storage/browser/kubernetes-charts-incubator
+ +```bash +helm install stable/nginx-ingress --name nginx-ing --namespace app +kubectl get all -n app +helm list +helm delete --help +helm delete nginx-ing --purge +``` + +### Managing dependencies +```bash +mkdir -p $HOME/dev/tools_data +cd ~/dev/tools_data +git clonehttps://github.com/helm/charts.git +cd charts/stable +cd sonarqube +cat requirements.yaml +mkdir charts/postgresql +cp -R ../postgresql charts/postgresql +helm install . --name sonarqube --namespace app -f values.yaml +helm list +``` + +#### Helm Commands +```bash +helm status sonarqube +helm inspect . +helm inspect stable/mysql +``` +change limits in values.yaml
+```yaml +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi +``` +```bash +helm upgrade sonarqube . -f values.yaml +helm history sonarqube +helm rollback --dry-run=true sonarqube 1 +helm rollback sonarqube 1 +kubectl get pods -n app +``` +