export KUBECONFIG=/etc/kubernetes/admin.conf
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
kubectl apply -f nginx-deploy.yaml
kubectl get deployment.apps/nginx
kubectl describe deployment.apps/nginx
Name: nginx
Namespace: default
CreationTimestamp: Fri, 17 Dec 2021 19:48:51 +0800
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=nginx
Replicas: 1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available False MinimumReplicasUnavailable
Progressing True ReplicaSetUpdated
OldReplicaSets: <none>
NewReplicaSet: nginx-6799fc88d8 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 79s deployment-controller Scaled up replica set nginx-6799fc88d8 to 1
kubectl get replicaset nginx-6799fc88d8
kubectl describe replicaset nginx-6799fc88d8
Name: nginx-6799fc88d8
Namespace: default
Selector: app=nginx,pod-template-hash=6799fc88d8
Labels: app=nginx
pod-template-hash=6799fc88d8
Annotations: deployment.kubernetes.io/desired-replicas: 1
deployment.kubernetes.io/max-replicas: 2
deployment.kubernetes.io/revision: 1
Controlled By: Deployment/nginx
Replicas: 1 current / 1 desired
Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=nginx
pod-template-hash=6799fc88d8
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 3m29s replicaset-controller Created pod: nginx-6799fc88d8-5pvr8
kubectl get pod nginx-6799fc88d8-5pvr8 -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-6799fc88d8-5pvr8 1/1 Running 0 5m10s 10.244.145.65 ecs-75909-0003 <none> <none>
curl 10.244.145.65
<!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>
kubectl edit deploy nginx
kubectl get pods -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-6799fc88d8-5pvr8 1/1 Running 0 46m 10.244.145.65 ecs-75909-0003 <none> <none>
nginx-6799fc88d8-t7rx5 1/1 Running 0 2m14s 10.244.145.66 ecs-75909-0003 <none> <none>
nginx-6799fc88d8-vbjvc 1/1 Running 0 2m14s 10.244.145.67 ecs-75909-0003 <none> <none>
kubectl get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-6799fc88d8-5pvr8 1/1 Running 0 51m app=nginx,pod-template-hash=6799fc88d8
nginx-6799fc88d8-t7rx5 1/1 Running 0 6m58s app=nginx,pod-template-hash=6799fc88d8
nginx-6799fc88d8-vbjvc 1/1 Running 0 6m58s app=nginx,pod-template-hash=6799fc88d8
kubectl expose deploy nginx --selector app=nginx --port=80 --type=NodePort
kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.1.0.1 <none> 443/TCP 36d
nginx NodePort 10.1.25.160 <none> 80:30884/TCP 2m46s
curl 10.1.25.160
<!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>
kubectl get ns default -v 9
cat /etc/kubernetes/admin.conf
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-add-repository "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main"
sudo apt-get update
sudo apt install kubelet kubeadm kubectl
sudo apt-mark hold kubeadm kubelet kubectl
kubelet --version
sudo swapoff -a
free -h
vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false"
systemctl daemon-reload
systemctl restart kubelet
kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --service-cidr=10.1.0.0/16 --kubernetes-version v1.22.3
export KUBECONFIG=/etc/kubernetes/admin.conf
kubeadm join 192.168.0.18:6443 --token 2pwout.v81y9ss6f4fjed87 \
--discovery-token-ca-cert-hash sha256:20bfbde6985f6337e7585742572707b72b4dd4da6c1a4af9260c8295129c8d01
watch kubectl get pods -n kube-system
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
ecs-75909-0001 Ready <none> 123m v1.22.3 192.168.0.61 <none> Ubuntu 18.04.5 LTS 4.15.0-136-generic docker://20.10.10
ecs-75909-0002 Ready control-plane,master 136m v1.22.3 192.168.0.18 <none> Ubuntu 18.04.5 LTS 4.15.0-136-generic docker://20.10.10
ecs-75909-0003 Ready <none> 122m v1.22.3 192.168.0.67 <none> Ubuntu 18.04.5 LTS 4.15.0-136-generic docker://20.10.10
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
https://docs.projectcalico.org/manifests/custom-resources.yaml
kubectl create -f custom-resources.yaml
watch kubectl get pods -n calico-system
watch kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
calico-apiserver calico-apiserver-6fb4f77d54-ljbgg 1/1 Running 0 116m
calico-apiserver calico-apiserver-6fb4f77d54-wxx96 1/1 Running 0 116m
calico-system calico-kube-controllers-7bbdc8dbd7-s9xrb 1/1 Running 0 124m
calico-system calico-node-b6rg5 1/1 Running 0 117m
calico-system calico-node-dsx2r 1/1 Running 0 116m
calico-system calico-node-t4xwh 1/1 Running 0 124m
calico-system calico-typha-879f64854-jbh8c 1/1 Running 0 116m
calico-system calico-typha-879f64854-rmgdw 1/1 Running 0 124m
kube-system coredns-7f6cbbb7b8-76dwt 1/1 Running 0 130m
kube-system coredns-7f6cbbb7b8-f74v2 1/1 Running 0 130m
kube-system etcd-ecs-75909-0002 1/1 Running 0 131m
kube-system kube-apiserver-ecs-75909-0002 1/1 Running 0 131m
kube-system kube-controller-manager-ecs-75909-0002 1/1 Running 0 131m
kube-system kube-proxy-8vzwg 1/1 Running 0 117m
kube-system kube-proxy-jchsf 1/1 Running 0 116m
kube-system kube-proxy-jnkbs 1/1 Running 0 130m
kube-system kube-scheduler-ecs-75909-0002 1/1 Running 0 131m
tigera-operator tigera-operator-78b8976b89-6h86f 1/1 Running 0 130m
kubectl taint nodes --all node-role.kubernetes.io/master-
kubeadm reset -f
kubectl delete -f https://docs.projectcalico.org/manifests/custom-resources.yaml