From 1af12da9e1d91530e35dff0833ddbe142fbf1805 Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Mon, 10 Sep 2018 23:49:25 +0300 Subject: [PATCH] lables - rc - rs - deployments --- 00-namespaces/resource-quota-lights.yaml | 7 ++++ 01-pods/kuard_volume.yaml | 4 +-- 01-pods/pvc-pod.yaml | 22 ++++++++++++ 03-other-specs/cassandra-pvc.yaml | 13 +++++++ 03-other-specs/cassandra-statefulset.yaml | 19 ++-------- 03-other-specs/deployment_kuard_health.yaml | 32 +++++++++++++++++ 04-labels/.Readme.md.swp | Bin 0 -> 12288 bytes 04-labels/1_kuard.yaml | 8 ++--- 04-labels/Readme.md | 17 ++++++++- 05-configmaps/apikey.txt | 1 + 05-configmaps/env-configmap.yaml | 8 +++++ 05-configmaps/env-pod.yaml | 24 +++++++++++++ 05-configmaps/my-config.yaml | 17 --------- 05-deployments/02-1.rs-pod.yaml | 23 ++++++++++++ 05-deployments/02-replicationset.yaml | 38 ++++++++++++++++++++ 05-deployments/ReadMe | 4 +++ 16 files changed, 196 insertions(+), 41 deletions(-) create mode 100644 00-namespaces/resource-quota-lights.yaml create mode 100644 01-pods/pvc-pod.yaml create mode 100644 03-other-specs/cassandra-pvc.yaml create mode 100644 03-other-specs/deployment_kuard_health.yaml create mode 100644 04-labels/.Readme.md.swp create mode 100644 05-configmaps/apikey.txt create mode 100644 05-configmaps/env-configmap.yaml create mode 100644 05-configmaps/env-pod.yaml delete mode 100644 05-configmaps/my-config.yaml create mode 100644 05-deployments/02-1.rs-pod.yaml create mode 100644 05-deployments/02-replicationset.yaml create mode 100644 05-deployments/ReadMe diff --git a/00-namespaces/resource-quota-lights.yaml b/00-namespaces/resource-quota-lights.yaml new file mode 100644 index 0000000..890ba24 --- /dev/null +++ b/00-namespaces/resource-quota-lights.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ResourceQuota +metadata: + name: quota +spec: + hard: + pods: "2" diff --git a/01-pods/kuard_volume.yaml b/01-pods/kuard_volume.yaml index 53e1d03..b768779 100644 --- a/01-pods/kuard_volume.yaml +++ b/01-pods/kuard_volume.yaml @@ -10,7 +10,7 @@ spec: volumes: - name: "kuard-data" hostPath: - path: /var/lib/kuard + path: /var/lib containers: - image: gcr.io/kuar-demo/kuard-amd64:1 imagePullPolicy: IfNotPresent @@ -31,4 +31,4 @@ spec: protocol: TCP resources: {} dnsPolicy: ClusterFirst - restartPolicy: OnFailure \ No newline at end of file + restartPolicy: OnFailure diff --git a/01-pods/pvc-pod.yaml b/01-pods/pvc-pod.yaml new file mode 100644 index 0000000..1296e53 --- /dev/null +++ b/01-pods/pvc-pod.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Pod +metadata: + name: my-site +spec: + containers: + - name: mysql + image: mysql + volumeMounts: + - mountPath: /var/lib/mysql + name: site-data + subPath: mysql + - name: php + image: php + volumeMounts: + - mountPath: /var/www/html + name: site-data + subPath: html + volumes: + - name: site-data + persistentVolumeClaim: + claimName: my-site-data diff --git a/03-other-specs/cassandra-pvc.yaml b/03-other-specs/cassandra-pvc.yaml new file mode 100644 index 0000000..90456d2 --- /dev/null +++ b/03-other-specs/cassandra-pvc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: cassandra-0 +spec: + storageClassName: "" + capacity: + storage: 10G + accessModes: + - ReadWriteOnce + gcePersistentDisk: + pdName: cassandra-disk + fsType: ext4 diff --git a/03-other-specs/cassandra-statefulset.yaml b/03-other-specs/cassandra-statefulset.yaml index dbcba6c..6564996 100644 --- a/03-other-specs/cassandra-statefulset.yaml +++ b/03-other-specs/cassandra-statefulset.yaml @@ -1,15 +1,10 @@ -apiVersion: apps/v1 +apiVersion: "apps/v1beta1" kind: StatefulSet metadata: name: cassandra - labels: - app: cassandra spec: serviceName: cassandra replicas: 3 - selector: - matchLabels: - app: cassandra template: metadata: labels: @@ -82,18 +77,8 @@ spec: volumeClaimTemplates: - metadata: name: cassandra-data - annotations: - volume.beta.kubernetes.io/storage-class: fast spec: accessModes: [ "ReadWriteOnce" ] resources: requests: - storage: 1Gi ---- -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: fast -provisioner: k8s.io/minikube-hostpath -parameters: - type: pd-ssd + storage: 10Gi diff --git a/03-other-specs/deployment_kuard_health.yaml b/03-other-specs/deployment_kuard_health.yaml new file mode 100644 index 0000000..0f8f8f3 --- /dev/null +++ b/03-other-specs/deployment_kuard_health.yaml @@ -0,0 +1,32 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: kuard-deployment +spec: + replicas: 2 + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + template: + metadata: + labels: + app: kuard + version: 1.0.0 + spec: + containers: + - name: kuard + image: gcr.io/kuar-demo/kuard-amd64:2 + resources: + requests: + memory: "1024Mi" + cpu: "1000m" + limits: + memory: "1024Mi" + cpu: "1000m" + ports: + - containerPort: 8080 + name: http + protocol: TCP + diff --git a/04-labels/.Readme.md.swp b/04-labels/.Readme.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..34a1621ef97fd75c555249eb7753ed448d2e6aea GIT binary patch literal 12288 zcmeI2O=}b}7{^n+NPWc@yrxs37Mj`Vi?9^egW$nKrBv*t6iH{E?M!zjiAknqsa0=^ zc+|V!!Gn17J9zcfZ{f{nc4u4Jx>Z3Bl_&6@WOkqY^W>M!z%tp0R_`zIW*9Lnml%^D z(zSbEuCu*_F(Zr2R-gZ(ELU+(EXnw;)*Z2Ib(rf|=EL2d^$Z&cY&VS6TM&EKkTE1s zNR>1?1AOt`RMWTy6liRzM~Ngasx>g$NLVKO<23wrHMzG(R`n+v=0S z1iy0m(VuxxG!Y;IM1Tko0U|&IhyW2F0wq}#HdNQQR1pCpKm>>Y z5g-CYfCvx)B0vO)01+SpCy;=|*Xi%Z85=u`$>aO~!T{67>M}4Sn9DZlO-2PN9062n21j*i9dk?r8si=KD93MGmX|jXTkrt@iBWTnH literal 0 HcmV?d00001 diff --git a/04-labels/1_kuard.yaml b/04-labels/1_kuard.yaml index a4956a6..dc7debe 100644 --- a/04-labels/1_kuard.yaml +++ b/04-labels/1_kuard.yaml @@ -3,21 +3,21 @@ kind: Deployment metadata: creationTimestamp: null labels: - appVersion: 1.0.0 - env: prod + appVersion: 2.0.0 + konu: meetup name: kuard spec: replicas: 2 selector: matchLabels: - appVersion: 1.0.0 + appVersion: 2.0.0 env: prod strategy: {} template: metadata: creationTimestamp: null labels: - appVersion: 1.0.0 + appVersion: 2.0.0 env: prod spec: containers: diff --git a/04-labels/Readme.md b/04-labels/Readme.md index 0b26799..47393b8 100644 --- a/04-labels/Readme.md +++ b/04-labels/Readme.md @@ -1,5 +1,20 @@ kubectl apply -f 1_kuard.yaml
kubectl get pods --show-labels
kubectl get pods -l appVersion=0.0.1
-kubectl get pods -l appVersion=1.0.0 +kubectl get pods -l appVersion=1.0.0
+kubectl get pods --all-namespaces -l appVersion!=1.0.0,app=prometheus
+kubectl get pods --all-namespaces -l "k8s-app in(heapster,kube-state-metrics)"
+kubectl get pods --all-namespaces -l "k8s-app notin(heapster,kube-state-metrics)"
+kubectl get pods --all-namespaces -l "k8s-app,k8s-app notin(heapster,kube-state-metrics)"
+kubectl get pods --field-selector=status.phase!=Running --all-namespaces
+kubectl get pods -o json | jq ".items[].status.containerStatuses[].name"
+kubectl port-forward $(kubectl get pods -o jsonpath={.items[0].metadata.name}) 8080:8080
+kubectl port-forward $(kubectl get pod — selector=weave-scope-component=app -o jsonpath={.items..metadata.name}) 4040
+ +#Modifying patch / labels / annotations when to restart +kubectl label nodes gke-prometheus-demo-default-pool-f423e0de-knrv konu=meetup
+kubectl patch deployment kuard -p '{"metadata": {"labels": {"version":"0.0.3"}}}'
+kubectl patch deployment kuard -p '"spec": {"template":{"metadata":{"labels":{"version":"2.0.0"}}}}'
+kubectl annotate deployment kuard durum=iyi
+ diff --git a/05-configmaps/apikey.txt b/05-configmaps/apikey.txt new file mode 100644 index 0000000..c087c3a --- /dev/null +++ b/05-configmaps/apikey.txt @@ -0,0 +1 @@ +Pamir \ No newline at end of file diff --git a/05-configmaps/env-configmap.yaml b/05-configmaps/env-configmap.yaml new file mode 100644 index 0000000..d5685b5 --- /dev/null +++ b/05-configmaps/env-configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +data: + log.enabled: "1" + log.type: "debug" + log.location: "file" +kind: ConfigMap +metadata: + name: logging diff --git a/05-configmaps/env-pod.yaml b/05-configmaps/env-pod.yaml new file mode 100644 index 0000000..efa42cc --- /dev/null +++ b/05-configmaps/env-pod.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Pod +metadata: + name: configpod +spec: + containers: + - name: config-pod + image: nginx + env: + - name: LOG_LOCATION + valueFrom: + configMapKeyRef: + name: logging + key: log.location + - name: LOGGING_TYPE + valueFrom: + configMapKeyRef: + name: logging + key: log.type + - name: LOGGING_ENABLED + valueFrom: + configMapKeyRef: + name: logging + key: log.enabled diff --git a/05-configmaps/my-config.yaml b/05-configmaps/my-config.yaml deleted file mode 100644 index bb3c452..0000000 --- a/05-configmaps/my-config.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -data: - log4j.xml: "\r\n\r\n\r\n\r\n\t\r\n\t \r\n\t\t\r\n\t \r\n\t\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n\r\n" - my-config.txt: "name=pamir\r\nsurname=erdem\r\nbestfriend=nazli" -kind: ConfigMap -metadata: - creationTimestamp: 2017-12-23T16:20:54Z - name: my-config - namespace: default - resourceVersion: "346218" - selfLink: /api/v1/namespaces/default/configmaps/my-config - uid: 3fbdac81-e7fd-11e7-a281-08002754b872 diff --git a/05-deployments/02-1.rs-pod.yaml b/05-deployments/02-1.rs-pod.yaml new file mode 100644 index 0000000..91047a6 --- /dev/null +++ b/05-deployments/02-1.rs-pod.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + app: guestbook + tier: frontend + name: frontend-pamir +spec: + containers: + - env: + - name: GET_HOSTS_FROM + value: dns + image: gcr.io/google_samples/gb-frontend:v3 + imagePullPolicy: IfNotPresent + name: php-redis + ports: + - containerPort: 80 + protocol: TCP + resources: + requests: + cpu: 100m + memory: 100Mi + dnsPolicy: ClusterFirst diff --git a/05-deployments/02-replicationset.yaml b/05-deployments/02-replicationset.yaml new file mode 100644 index 0000000..638f74e --- /dev/null +++ b/05-deployments/02-replicationset.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: ReplicaSet +metadata: + name: frontend + labels: + app: guestbook + tier: frontend +spec: + # modify replicas according to your case + replicas: 3 + selector: + #matchLabels: + # tier: frontend + matchExpressions: + - {key: tier, operator: In, values: [frontend]} + template: + metadata: + labels: + app: guestbook + tier: frontend + spec: + containers: + - name: php-redis + image: gcr.io/google_samples/gb-frontend:v3 + resources: + requests: + cpu: 100m + memory: 100Mi + env: + - name: GET_HOSTS_FROM + value: dns + # If your cluster config does not include a dns service, then to + # instead access environment variables to find service host + # info, comment out the 'value: dns' line above, and uncomment the + # line below. + # value: env + ports: + - containerPort: 80 diff --git a/05-deployments/ReadMe b/05-deployments/ReadMe new file mode 100644 index 0000000..58a1e57 --- /dev/null +++ b/05-deployments/ReadMe @@ -0,0 +1,4 @@ +kubectl apply -f 02-replicationset.yaml +kubectl get events -w +kubectl get rs -w +kubectl apply -f 02-1.rs-pod.yaml