update samples
This commit is contained in:
parent
b3a558e695
commit
a702e60990
25 changed files with 321 additions and 0 deletions
16
CKA_Course/advanced_allocation/daemonset.yaml
Normal file
16
CKA_Course/advanced_allocation/daemonset.yaml
Normal file
|
@ -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
|
9
CKA_Course/advanced_allocation/nodename.yaml
Normal file
9
CKA_Course/advanced_allocation/nodename.yaml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
nodeName: k8s-worker1
|
10
CKA_Course/advanced_allocation/nodeselector.yaml
Normal file
10
CKA_Course/advanced_allocation/nodeselector.yaml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
nodeSelector:
|
||||||
|
myLabel: myvalue
|
19
CKA_Course/deployment.yaml
Normal file
19
CKA_Course/deployment.yaml
Normal file
|
@ -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
|
21
CKA_Course/networkpolicy.yaml
Normal file
21
CKA_Course/networkpolicy.yaml
Normal file
|
@ -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
|
15
CKA_Course/pods/configurations/config-map.yaml
Normal file
15
CKA_Course/pods/configurations/config-map.yaml
Normal file
|
@ -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.
|
5
CKA_Course/pods/configurations/config-vol.yaml
Normal file
5
CKA_Course/pods/configurations/config-vol.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
...
|
||||||
|
volumes:
|
||||||
|
- name: secret-vol
|
||||||
|
secret:
|
||||||
|
secretName: my-secret
|
9
CKA_Course/pods/configurations/env-vars.yaml
Normal file
9
CKA_Course/pods/configurations/env-vars.yaml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- ...
|
||||||
|
env:
|
||||||
|
- name: ENVVAR
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: my-configmap
|
||||||
|
key: mykey
|
9
CKA_Course/pods/configurations/secret.yaml
Normal file
9
CKA_Course/pods/configurations/secret.yaml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: my-secret
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
username: user
|
||||||
|
password: mypass
|
||||||
|
|
14
CKA_Course/pods/health/liveness-http.yaml
Normal file
14
CKA_Course/pods/health/liveness-http.yaml
Normal file
|
@ -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
|
14
CKA_Course/pods/health/liveness.yaml
Normal file
14
CKA_Course/pods/health/liveness.yaml
Normal file
|
@ -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
|
14
CKA_Course/pods/health/readiness.yaml
Normal file
14
CKA_Course/pods/health/readiness.yaml
Normal file
|
@ -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
|
10
CKA_Course/pods/health/restart-always.yaml
Normal file
10
CKA_Course/pods/health/restart-always.yaml
Normal file
|
@ -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"]
|
10
CKA_Course/pods/health/restart-never.yaml
Normal file
10
CKA_Course/pods/health/restart-never.yaml
Normal file
|
@ -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"]
|
10
CKA_Course/pods/health/restart-onfailure.yaml
Normal file
10
CKA_Course/pods/health/restart-onfailure.yaml
Normal file
|
@ -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"]
|
14
CKA_Course/pods/health/startup.yaml
Normal file
14
CKA_Course/pods/health/startup.yaml
Normal file
|
@ -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
|
12
CKA_Course/pods/init-container.yaml
Normal file
12
CKA_Course/pods/init-container.yaml
Normal file
|
@ -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" ]
|
12
CKA_Course/pods/resources/limits.yaml
Normal file
12
CKA_Course/pods/resources/limits.yaml
Normal file
|
@ -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
|
12
CKA_Course/pods/resources/requests.yaml
Normal file
12
CKA_Course/pods/resources/requests.yaml
Normal file
|
@ -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
|
21
CKA_Course/pods/sidecar.yaml
Normal file
21
CKA_Course/pods/sidecar.yaml
Normal file
|
@ -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: {}
|
32
CKA_Course/services/clusterip.yaml
Normal file
32
CKA_Course/services/clusterip.yaml
Normal file
|
@ -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
|
33
CKA_Course/services/nodeport.yaml
Normal file
33
CKA_Course/services/nodeport.yaml
Normal file
|
@ -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
|
Loading…
Reference in a new issue