Create a deployment with a service and a pod, and then expose the pod on the node
kubectl create deployment nginx-skobba --image=nginx --port=80
kubectl expose pod nginx-skobba-xxxxxxx --type NodePort --port 80
# or
kubectl expose deployment nginx-skobba --type=NodePort --port=80
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: host-path-deploy
name: host-path-deploy
namespace: skobba
spec:
replicas: 1
selector:
matchLabels:
app: host-path-deploy
template:
metadata:
labels:
app: host-path-deploy
spec:
containers:
- image: nginx:alpine
name: nginx
volumeMounts:
- name: host-path-volume
mountPath: /myvol
volumes:
- name: host-path-volume
persistentVolumeClaim:
claimName: host-path-pvc
EOF
# Show history
kubectl rollout history deployment mydep
# Show a spesific revision
kubectl rollout history deployment mydep --revision=3
# Show status
kubectl rollout status deployment mydep
# Rollback one (not the new rev number)
kubectl rollout undo deployment mydep
# Rollback to a spesific version
kubectl rollout undo deployment mydep --to-revision=3
kubectl get pod -n myns mypod -oyaml
metadata.creationTimestamp
metadata.resourceVersion
metadata.selfLink
metadata.uid
metadata.annotations (if it contains auto-generated data like kubectl.kubernetes.io/last-applied-configuration)
status (the entire status section can be removed)
spec.nodeName
spec.serviceAccountName.
kind: Deployment
apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mydep
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: mycontainer
image: nginx
ports:
- containerPort: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: mydep
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: mycontainer
image: nginx
ports:
- containerPort: 80
Pod:
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mycontainer
image: nginx
ports:
- containerPort: 80
Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mydep
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: mycontainer
image: nginx
ports:
- containerPort: 80
kubectl get deployments --all-namespaces -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,CPU_REQUEST:.spec.template.spec.containers[*].resources.requests.cpu,MEM_REQUEST:.spec.template.spec.containers[*].resources.requests.memory,CPU_LIMIT:.spec.template.spec.containers[*].resources.limits.cpu,MEM_LIMIT:.spec.template.spec.containers[*].resources.limits.memory