busybox
docker imagekubectl run myshell -it --image busybox -- sh
kubectl get pods
NAMESPACE NAME READY STATUS RESTARTS AGE
default myshell 1/1 Running 1 (2m26s ago) 7m14s
kubectl delete pods myshell
pod "myshell" deleted
From kube-master there is no pod named myshell
kubectl get pods
NAMESPACE NAME READY STATUS RESTARTS AGE
kubectl create deployment mynginx --image=nginx
deployment.apps/mynginx created
kubectl get pods
NAME READY STATUS RESTARTS AGE
mynginx-56766fcf49-mb8vn 1/1 Running 0 12m
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mynginx-56766fcf49-mb8vn 1/1 Running 0 15m 10.244.2.3 kube-node2 <none> <none>
kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
mynginx 1/1 1 1 17m
kubectl get deploy -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
mynginx 1/1 1 1 17m nginx nginx app=mynginx
If we delete a pod, a new pod will be created automatically.
This is the difference between create a pod and create a deployment.
kubectl delete pods mynginx-56766fcf49-mb8vn
pod "mynginx-56766fcf49-mb8vn" deleted
kubectl get pods
NAME READY STATUS RESTARTS AGE
mynginx-56766fcf49-n6wlb 1/1 Running 0 11m
A new pod has been created automatically
This will delete both the pods and the deployment.
kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
mynginx 1/1 1 1 44m
kubectl delete deploy mynginx
deployment.apps "mynginx" deleted
kubectl get deploy
No resources found in default namespace.
Aims to provide access to our pods
Port are exposed in a range of 30000:32767
Required: have a pod running.
Services, Load Balancing, and Networking
kubectl create service nodeport mynginx --tcp=8080:80
service/nginx created
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 23h
mynginx NodePort 10.105.145.254 <none> 8080:30686/TCP 65s
mynginx exposed port is: 30686
kubectl describe pod mynginx |grep Node:
Node: kube-node2/192.168.56.42
worker-node is: kube-node2/192.168.56.42
curl 192.168.56.42:30686
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>