20201215 kubernetes (三)
課堂資訊
Proxy Server
Proxy
正向代理伺服器
客戶端
反向代理伺服器
服務器
Ingress

課堂練習
Ingress
創建部署
cd test-ingress-nginxkubectl apply -f mandatory.yamlkubectl apply -f service-nodeport.yamllsgedit service-nodeport.yaml mandatory.yaml &
kubectl get deploymentkubectl get deployment -n ingress-nginxkubectl get svc -n ingress-nginxkubectl get pods -n ingress-nginx
創建 Ingress,代理到後端 nginx 服務
kubectl get deploymentkubectl delete deployment mywebkubectl delete svc mywebkubectl get svckubectl apply -f httpd.yamlgedit httpd.yamlkubectl get deploymentkubectl get svcgedit ingress-httpd.yaml
curl [httpd_CLUSTER-IP]kubectl apply -f ingress-httpd.yamlkubectl get ingresskubectl get svckubectl get pod -n ingress-nginxkubectl get pod -n ingress-nginx -o wide

kubectl get pod
kubectl get pod -o widekubectl exec [vm3_httpdName] -it -- bashcd htdocs/echo "vm3 www.a.com" > hi.htmlsexit
kubectl exec [vm2_httpdName] -it -- bashcd htdocs/echo "vm2 www.a.com" > hi.htmlsexit
cp httpd.yaml httpd2.yamlcp ingress-httpd.yaml ingress-httpd2.yamlgedit httpd2.yaml ingress-httpd2.yaml

kubectl apply -f httpd2.yamlkubectl apply -f ingress-httpd2.yamlkubectl get ingresskubectl get podkubectl exec [http2_Name] -it -- bashcd htdocs/echo "www.b.com" > hi.htm
Deployment
kubectl get deploymentkubectl describe deployment httpd
kubectl get replicasetkubectl get deployment httpd2kubectl edit deployment httpd2cdls
kubectl apply -f cronjob.ymlkubectl get podcat cronjob.ymlkubectl get pod -o wide
Last updated
Was this helpful?