From a702e60990db63d8b3b279e7f3e544c19b79a595 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Tue, 16 Aug 2022 21:59:58 -0500 Subject: [PATCH] update samples --- CKA_Course/advanced_allocation/daemonset.yaml | 16 +++++++++ CKA_Course/advanced_allocation/nodename.yaml | 9 +++++ .../advanced_allocation/nodeselector.yaml | 10 ++++++ CKA_Course/deployment.yaml | 19 +++++++++++ CKA_Course/networkpolicy.yaml | 21 ++++++++++++ .../pods/configurations/config-map.yaml | 15 +++++++++ .../pods/configurations/config-vol.yaml | 5 +++ CKA_Course/pods/configurations/env-vars.yaml | 9 +++++ CKA_Course/pods/configurations/secret.yaml | 9 +++++ CKA_Course/pods/health/liveness-http.yaml | 14 ++++++++ CKA_Course/pods/health/liveness.yaml | 14 ++++++++ CKA_Course/pods/health/readiness.yaml | 14 ++++++++ CKA_Course/pods/health/restart-always.yaml | 10 ++++++ CKA_Course/pods/health/restart-never.yaml | 10 ++++++ CKA_Course/pods/health/restart-onfailure.yaml | 10 ++++++ CKA_Course/pods/health/startup.yaml | 14 ++++++++ CKA_Course/pods/init-container.yaml | 12 +++++++ CKA_Course/pods/resources/limits.yaml | 12 +++++++ CKA_Course/pods/resources/requests.yaml | 12 +++++++ CKA_Course/pods/sidecar.yaml | 21 ++++++++++++ CKA_Course/{ => rbac}/role-pod-reader.yaml | 0 .../{ => rbac}/rolebinding-sa-pod-reader.yaml | 0 .../{ => rbac}/sa-my-service-account.yaml | 0 CKA_Course/services/clusterip.yaml | 32 ++++++++++++++++++ CKA_Course/services/nodeport.yaml | 33 +++++++++++++++++++ 25 files changed, 321 insertions(+) create mode 100644 CKA_Course/advanced_allocation/daemonset.yaml create mode 100644 CKA_Course/advanced_allocation/nodename.yaml create mode 100644 CKA_Course/advanced_allocation/nodeselector.yaml create mode 100644 CKA_Course/deployment.yaml create mode 100644 CKA_Course/networkpolicy.yaml create mode 100644 CKA_Course/pods/configurations/config-map.yaml create mode 100644 CKA_Course/pods/configurations/config-vol.yaml create mode 100644 CKA_Course/pods/configurations/env-vars.yaml create mode 100644 CKA_Course/pods/configurations/secret.yaml create mode 100644 CKA_Course/pods/health/liveness-http.yaml create mode 100644 CKA_Course/pods/health/liveness.yaml create mode 100644 CKA_Course/pods/health/readiness.yaml create mode 100644 CKA_Course/pods/health/restart-always.yaml create mode 100644 CKA_Course/pods/health/restart-never.yaml create mode 100644 CKA_Course/pods/health/restart-onfailure.yaml create mode 100644 CKA_Course/pods/health/startup.yaml create mode 100644 CKA_Course/pods/init-container.yaml create mode 100644 CKA_Course/pods/resources/limits.yaml create mode 100644 CKA_Course/pods/resources/requests.yaml create mode 100644 CKA_Course/pods/sidecar.yaml rename CKA_Course/{ => rbac}/role-pod-reader.yaml (100%) rename CKA_Course/{ => rbac}/rolebinding-sa-pod-reader.yaml (100%) rename CKA_Course/{ => rbac}/sa-my-service-account.yaml (100%) create mode 100644 CKA_Course/services/clusterip.yaml create mode 100644 CKA_Course/services/nodeport.yaml diff --git a/CKA_Course/advanced_allocation/daemonset.yaml b/CKA_Course/advanced_allocation/daemonset.yaml new file mode 100644 index 0000000..e2b5608 --- /dev/null +++ b/CKA_Course/advanced_allocation/daemonset.yaml @@ -0,0 +1,16 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: my-daemonset +spec: + selector: + matchLabels: + app: my-daemonset + template: + metadata: + labels: + app: my-damonset + spec: + containers: + - name: nginx + image: nginx:1.19.1 diff --git a/CKA_Course/advanced_allocation/nodename.yaml b/CKA_Course/advanced_allocation/nodename.yaml new file mode 100644 index 0000000..1e88220 --- /dev/null +++ b/CKA_Course/advanced_allocation/nodename.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx + nodeName: k8s-worker1 diff --git a/CKA_Course/advanced_allocation/nodeselector.yaml b/CKA_Course/advanced_allocation/nodeselector.yaml new file mode 100644 index 0000000..2b62aac --- /dev/null +++ b/CKA_Course/advanced_allocation/nodeselector.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx + nodeSelector: + myLabel: myvalue diff --git a/CKA_Course/deployment.yaml b/CKA_Course/deployment.yaml new file mode 100644 index 0000000..092178c --- /dev/null +++ b/CKA_Course/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment +spec: + replicas: 3 + selector: + matchLabels: + app: my-deployment + template: + metadata: + labels: + app: my-deployment + spec: + containers: + - name: nginx + image: nginx:1.19.1 + ports: + - containerPort: 80 diff --git a/CKA_Course/networkpolicy.yaml b/CKA_Course/networkpolicy.yaml new file mode 100644 index 0000000..4971d70 --- /dev/null +++ b/CKA_Course/networkpolicy.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: my-network-policy +spec: + podSelector: + matchLabels: + role: db + ingress: + - from: + - podSelector: + matchLabels: + app: db + egress: + - to: + - namespaceSelector: + matchLabels: + app: web + ports: + - protocol: TCP + port: 80 diff --git a/CKA_Course/pods/configurations/config-map.yaml b/CKA_Course/pods/configurations/config-map.yaml new file mode 100644 index 0000000..5e8ccec --- /dev/null +++ b/CKA_Course/pods/configurations/config-map.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-configmap +data: + key1: value1 + key2: value2 + key3: + subkey: + morekeys: data + evenmore: some more data + key4: | + You can also do + multi-line + data. diff --git a/CKA_Course/pods/configurations/config-vol.yaml b/CKA_Course/pods/configurations/config-vol.yaml new file mode 100644 index 0000000..36784d9 --- /dev/null +++ b/CKA_Course/pods/configurations/config-vol.yaml @@ -0,0 +1,5 @@ +... +volumes: +- name: secret-vol + secret: + secretName: my-secret diff --git a/CKA_Course/pods/configurations/env-vars.yaml b/CKA_Course/pods/configurations/env-vars.yaml new file mode 100644 index 0000000..3f56e8b --- /dev/null +++ b/CKA_Course/pods/configurations/env-vars.yaml @@ -0,0 +1,9 @@ +spec: + containers: + - ... + env: + - name: ENVVAR + valueFrom: + configMapKeyRef: + name: my-configmap + key: mykey diff --git a/CKA_Course/pods/configurations/secret.yaml b/CKA_Course/pods/configurations/secret.yaml new file mode 100644 index 0000000..b9096f9 --- /dev/null +++ b/CKA_Course/pods/configurations/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: my-secret +type: Opaque +data: + username: user + password: mypass + diff --git a/CKA_Course/pods/health/liveness-http.yaml b/CKA_Course/pods/health/liveness-http.yaml new file mode 100644 index 0000000..b0aa1a9 --- /dev/null +++ b/CKA_Course/pods/health/liveness-http.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: liveness-pod-http +spec: + containers: + - name: nginx + image: nginx:1.19.1 + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 5 diff --git a/CKA_Course/pods/health/liveness.yaml b/CKA_Course/pods/health/liveness.yaml new file mode 100644 index 0000000..97728bf --- /dev/null +++ b/CKA_Course/pods/health/liveness.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: liveness-pod +spec: + containers: + - name: busybox + image: busybox + command: ["sh", "-c", "while true; do sleep 3600; done"] + livenessProbe: + exec: + command: ["echo", "Hello, World!"] + initialDelaySeconds: 5 # start probing 5s after container start + periodSeconds: 5 # probe every 5 seconds diff --git a/CKA_Course/pods/health/readiness.yaml b/CKA_Course/pods/health/readiness.yaml new file mode 100644 index 0000000..a52276e --- /dev/null +++ b/CKA_Course/pods/health/readiness.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: readiness-pod +spec: + containers: + - name: nginx + image: nginx:1.19.1 + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 5 diff --git a/CKA_Course/pods/health/restart-always.yaml b/CKA_Course/pods/health/restart-always.yaml new file mode 100644 index 0000000..691ce33 --- /dev/null +++ b/CKA_Course/pods/health/restart-always.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: always-pod +spec: + restartPolicy: Always + containers: + - name: busybox + image: busybox + command: ["sh", "-c", "sleep 10"] diff --git a/CKA_Course/pods/health/restart-never.yaml b/CKA_Course/pods/health/restart-never.yaml new file mode 100644 index 0000000..edc2e5c --- /dev/null +++ b/CKA_Course/pods/health/restart-never.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: never-pod +spec: + restartPolicy: Never + containers: + - name: busybox + image: busybox + command: ["sh", "-c", "sleep 10"] diff --git a/CKA_Course/pods/health/restart-onfailure.yaml b/CKA_Course/pods/health/restart-onfailure.yaml new file mode 100644 index 0000000..9a253b6 --- /dev/null +++ b/CKA_Course/pods/health/restart-onfailure.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: onfailure-pod +spec: + restartPolicy: OnFailure + containers: + - name: busybox + image: busybox + command: ["sh", "-c", "sleep 10"] diff --git a/CKA_Course/pods/health/startup.yaml b/CKA_Course/pods/health/startup.yaml new file mode 100644 index 0000000..46b43b7 --- /dev/null +++ b/CKA_Course/pods/health/startup.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: startup-pod +spec: + containers: + - name: nginx + image: nginx:1.19.1 + startupProbe: + httpGet: + path: / + port: 80 + failureThreshold: 30 + periodSeconds: 10 diff --git a/CKA_Course/pods/init-container.yaml b/CKA_Course/pods/init-container.yaml new file mode 100644 index 0000000..4079f85 --- /dev/null +++ b/CKA_Course/pods/init-container.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: init-pod +spec: + containers: + - name: nginx + image: nginx:1.19.1 + initContainers: + - name: delay + image: busybox + command: [ "sleep", "30" ] diff --git a/CKA_Course/pods/resources/limits.yaml b/CKA_Course/pods/resources/limits.yaml new file mode 100644 index 0000000..4d3b29a --- /dev/null +++ b/CKA_Course/pods/resources/limits.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: my-pod +spec: + containers: + - name: busybox + image:busybox + resources: + limits: + cpu: "250m" # 250 milliCPU = 1/4 CPU + memory: "128Mi" # 128 mebibytes diff --git a/CKA_Course/pods/resources/requests.yaml b/CKA_Course/pods/resources/requests.yaml new file mode 100644 index 0000000..ec4bb97 --- /dev/null +++ b/CKA_Course/pods/resources/requests.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: my-pod +spec: + containers: + - name: busybox + image:busybox + resources: + requests: + cpu: "250m" # 250 milliCPU = 1/4 CPU + memory: "128Mi" # 128 mebibytes diff --git a/CKA_Course/pods/sidecar.yaml b/CKA_Course/pods/sidecar.yaml new file mode 100644 index 0000000..5ba0d6c --- /dev/null +++ b/CKA_Course/pods/sidecar.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: sidecar-pod +spec: + containers: + - name: busybox1 + image: busybox + command: ['sh', '-c', 'while true; do echo logs data > /output/output.log; sleep 5; done'] + volumeMounts: + - name: sharedVol + mountPath: /output + - name: sidecar + image: busybox + command: ['sh', '-c', 'tail -f /intput/output.log'] + volumeMounts: + - name: sharedVol + mountPath: /input + volumes: + - name: sharedVol + emptyDir: {} diff --git a/CKA_Course/role-pod-reader.yaml b/CKA_Course/rbac/role-pod-reader.yaml similarity index 100% rename from CKA_Course/role-pod-reader.yaml rename to CKA_Course/rbac/role-pod-reader.yaml diff --git a/CKA_Course/rolebinding-sa-pod-reader.yaml b/CKA_Course/rbac/rolebinding-sa-pod-reader.yaml similarity index 100% rename from CKA_Course/rolebinding-sa-pod-reader.yaml rename to CKA_Course/rbac/rolebinding-sa-pod-reader.yaml diff --git a/CKA_Course/sa-my-service-account.yaml b/CKA_Course/rbac/sa-my-service-account.yaml similarity index 100% rename from CKA_Course/sa-my-service-account.yaml rename to CKA_Course/rbac/sa-my-service-account.yaml diff --git a/CKA_Course/services/clusterip.yaml b/CKA_Course/services/clusterip.yaml new file mode 100644 index 0000000..2426754 --- /dev/null +++ b/CKA_Course/services/clusterip.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: Service +metadata: + name: svc-clusterip +spec: + type: ClusterIP + selector: + app: svc-example + ports: + - protocol: TCP + port: 80 + targetPort: 80 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deployment-svc-example +spec: + replicas: 3 + selector: + matchLabels: + app: svc-example + template: + metadata: + labels: + app: svc-example + spec: + containers: + - name: nginx + image: nginx:1.19.1 + ports: + - containerPort: 80 diff --git a/CKA_Course/services/nodeport.yaml b/CKA_Course/services/nodeport.yaml new file mode 100644 index 0000000..4515af5 --- /dev/null +++ b/CKA_Course/services/nodeport.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: Service +metadata: + name: svc-clusterip +spec: + type: NodePort + selector: + app: svc-example + ports: + - protocol: TCP + port: 80 + targetPort: 80 + nodePort: 30080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deployment-svc-example +spec: + replicas: 3 + selector: + matchLabels: + app: svc-example + template: + metadata: + labels: + app: svc-example + spec: + containers: + - name: nginx + image: nginx:1.19.1 + ports: + - containerPort: 80