update samples

This commit is contained in:
John Bowdre 2022-08-16 21:59:58 -05:00
parent b3a558e695
commit a702e60990
25 changed files with 321 additions and 0 deletions

View 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

View file

@ -0,0 +1,9 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
nodeName: k8s-worker1

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
nodeSelector:
myLabel: myvalue

View 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

View 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

View 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.

View file

@ -0,0 +1,5 @@
...
volumes:
- name: secret-vol
secret:
secretName: my-secret

View file

@ -0,0 +1,9 @@
spec:
containers:
- ...
env:
- name: ENVVAR
valueFrom:
configMapKeyRef:
name: my-configmap
key: mykey

View file

@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
data:
username: user
password: mypass

View 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

View 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

View 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

View 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"]

View 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"]

View 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"]

View 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

View 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" ]

View 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

View 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

View 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: {}

View 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

View 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