kubectl describe nodes | grep -i taint
kubectl taint nodes --all node-role.kubernetes.io/master
kubectl api-resources
apiVersion: v1
kind: Pod
metadata:
name: basicpod
labels:
type: webserver
spec:
containers:
- name: webcont
image: nginx
ports:
- containerPort: 80
kubectl create -f basic.yaml
kubectl get pod -o wide
kubectl delete pod basicpod
apiVersion: v1
kind: Service
metadata:
name: basicservice
spec:
selector:
type: webserver
ports:
- protocol: TCP
port: 80
kubectl create -f basicservice.yaml
apiVersion: v1
kind: Pod
metadata:
name: basicpod
labels:
type: webserver
spec:
containers:
- name: webcont
image: nginx
ports:
- containerPort: 80
- name: fdlogger
image: fluent/fluentd
kubectl create -f basic.yaml
kubectl create deployment firstpod --image=nginx
kubectl get pod -n mynamespace
kubectl get pod --all-namespaces
kubectl get deploy,rs,po,svc,ep
k create deployment try1 --image=nginx
k scale deployment try1 --replicas=2
k get deployment try1 -o yaml > nginx.yaml
k create -f nginx.yaml
- image: nginx
imagePullPolicy: Always
name: nginx
readinessProbe:
periodSeconds: 5
exec:
command:
- cat
- /tmp/healthy
- name: goproxy
image: k8s.gcr.io/goproxy:0.1
ports:
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
k exec -it podName-123ad2 -- /bin/bash
k exec -it podName-123ad2 -c nginx -- /bin/bash
apiVersion: batch/v1
kind: Job
metadata:
name: sleepy
spec:
template:
spec:
containers:
- name: resting
image: busybox
command: ["/bin/sleep"]
args: ["3"]
restartPolicy: Never
k create -f job.yaml
k get job sleepy -o yaml
apiVersion: batch/v1
kind: Job
metadata:
name: sleepy
spec:
completions: 5
template:
spec:
containers:
- name: resting
image: busybox
command: ["/bin/sleep"]
args: ["3"]
restartPolicy: Never
k create -f job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: sleepy
spec:
completions: 5
parallelism: 2
template:
spec:
containers:
- name: resting
image: busybox
command: ["/bin/sleep"]
args: ["3"]
restartPolicy: Never
k create -f job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: sleepy
spec:
activeDeadlineSeconds: 15
template:
spec:
containers:
- name: resting
image: busybox
command: ["/bin/sleep"]
args: ["3"]
restartPolicy: Never
k create -f job.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: sleepy
spec:
schedule: "*/2 * * * *"
jobTemplate:
spec:
activeDeadlineSeconds: 10
template:
spec:
containers:
- name: resting
image: busybox
command: ["/bin/sleep"]
args: ["3"]
restartPolicy: Never
k create -f cronjob.yaml
k get pods -l app=app1
k create deployment limited --image=busybox --dry-run=client -o yaml
This should output a deployment without limits/requests:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: limited
name: limited
spec:
replicas: 1
selector:
matchLabels:
app: limited
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: limited
spec:
containers:
- image: busybox
name: busybox
resources: {}
status: {}
Edit and add limits/requests:
...
spec:
containers:
- image: busybox
name: busybox
resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "0.5"
memory: "500Mi"
...
apiVersion: v1
kind: Pod
metadata:
name: init-tester
labels:
app: inittest
spec:
containers:
- name: webservice
image: nginx
initContainers:
- name: failed
image: busybox
command: [/bin/true]
k create -f init-tester.yaml
k get crd
Preparation:
7803 echo c > primary/cyan
7809 echo m > primary/magenta
7810 echo y > primary/yellow
7811 echo k > primary/black
7812 echo "known as key" >> primary/black
7813 echo blue > favorite
kubectl create configmap colors \
--from-literal=text=black \
--from-file=./favorite \
--from-file=./primary/
kubectl get configmap colors -o yaml
Use previously configured ConfigMap value in a pod, and check if value is available in the container
...
spec:
containers:
- image: nginx
env:
- name: ilike
valueFrom:
configMapKeyRef:
name: colors
key: favorite
imagePullPolicy: Always
...
...
spec:
containers:
- image: nginx
env:
- name: ilike
valueFrom:
configMapKeyRef:
name: colors
key: favorite
envFrom:
- confingMapRef:
name: colors
imagePullPolicy: Always
...
kubectl exec -c nginx -it try1-1234sd -- /bin/bash -c'echo $ilike'
apiVersion: v1
kind: ConfigMap
metadata:
name: fast-car
namespace: default
data:
car.make: Ford
car.model: Mustang
car.trim: Shelby
k create -f car-map.yaml
...
spec:
containers:
- image: nginx
volumeMounts:
- mountPath: /etc/cars
name: car-vol
env:
- name: ilike
...
securityContext:{}
volumes:
- name: car-vol
configMap::
defaultMode: 420
name: fast-car
...
apiVersion: v1
kind: PersistentVolume
metadata:
name: pvvol-1
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
path: /opt/sfw
server: cp
readOnly: false
k create -f PVol.yaml
k get pv
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-one
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 200Mi
k create -f pvc.yaml
After creating PVC, the status of PV should change to Bound
...
spec:
containers:
- image: nginx
volumeMounts:
- mountPath: /opt
name: nfs-vol
...
securityContext:{}
volumes:
- name: nfs-vol
persistentVolumeClaim:
claimName: pvc-one
...
k rollout history deployment deploymentName
k rollout history deployment deploymentName --revision=1 > one.out
k rollout history deployment deploymentName --revision=2 > two.out
diff one.out two.out
kubectl rollout undo --dry-run=client deployment/deploymentName
kubectl rollout undo deployment deploymentName --to-revision=1