20201215 kubernetes (三)

課堂資訊

Proxy Server

Proxy

正向代理伺服器

客戶端

反向代理伺服器

服務器

Ingress

工作示意圖

課堂練習

Ingress

創建部署

cd test-ingress-nginx
kubectl apply -f mandatory.yaml
kubectl apply -f service-nodeport.yaml
ls
gedit service-nodeport.yaml mandatory.yaml &
kubectl get deployment
kubectl get deployment -n ingress-nginx
kubectl get svc -n ingress-nginx
kubectl get pods -n ingress-nginx

創建 Ingress,代理到後端 nginx 服務

kubectl get deployment
kubectl delete deployment myweb
kubectl delete svc myweb
kubectl get svc
kubectl apply -f httpd.yaml
gedit httpd.yaml
kubectl get deployment
kubectl get svc
gedit ingress-httpd.yaml

modifyserviceName tohttpd

curl [httpd_CLUSTER-IP]
kubectl apply -f ingress-httpd.yaml
kubectl get ingress
kubectl get svc
kubectl get pod -n ingress-nginx
kubectl get pod -n ingress-nginx -o wide

modifyC:\Windows\System32\drivers\etc 中的hosts

192.168.8.130          www.a.com
192.168.8.131          www.a.com
kubectl get pod
kubectl get pod -o wide
kubectl exec [vm3_httpdName] -it -- bash
cd htdocs/
echo "vm3 www.a.com" > hi.htm
ls
exit
kubectl exec [vm2_httpdName] -it -- bash
cd htdocs/
echo "vm2 www.a.com" > hi.htm
ls
exit
cp httpd.yaml httpd2.yaml
cp ingress-httpd.yaml ingress-httpd2.yaml
gedit httpd2.yaml ingress-httpd2.yaml
kubectl apply -f httpd2.yaml
kubectl apply -f ingress-httpd2.yaml
kubectl get ingress
kubectl get pod
kubectl exec [http2_Name] -it -- bash
cd htdocs/
echo "www.b.com" > hi.htm

Deployment

kubectl get deployment
kubectl describe deployment httpd
kubectl get replicaset
kubectl get deployment httpd2
kubectl edit deployment httpd2
cd
ls
kubectl apply -f cronjob.yml
kubectl get pod
cat cronjob.yml
kubectl get pod -o wide

Last updated

Was this helpful?