目錄
???????免費獲取題庫配套?CKA_v1.31_模擬系統?
一、題目
二、核心考點
Ingress 資源定義
Ingress Controller 依賴
服務暴露驗證
網絡層次關系
三、搭建模擬環境
1.創建命名空間
2.安裝ingress ingress-nginx-controller
3.創建hello.yaml并部署
?四、總結
????免費獲取題庫配套?CKA_v1.31_模擬系統?
一、題目
您必須在以下Cluster/Node上完成此考題: ? ?
? Cluster ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Master node ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Worker node
? ??hk8s ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? master ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? node01
設置配置環境:
[candidate@node01]$ ?kubectl config use-context hk8s
.
Context
將外部流量按照ingress規則引入內部服務
.
Task
如下創建一個新的 nginx Ingress 資源:
.
name : ping
namespace : ing-internal
.
使用服務端口 5678 ?在路徑 /hello 上公開服務 hello 。 可以使用以下命令檢查服務 hello ?的可用性,該命令應返回 hello :
.
curl -kL INTERNAL_IP/hello
二、核心考點
-
Ingress 資源定義
-
名稱與命名空間規范:
name: ping
,?namespace: ing-internal
-
路徑與服務端口映射:
/hello
?→?service hello:5678
-
-
Ingress Controller 依賴
-
必須部署 Nginx Ingress Controller
-
控制器與 Ingress 資源的關聯機制
-
-
服務暴露驗證
-
獲取 Ingress 訪問端點(INTERNAL_IP)
-
使用?
curl -kL
?測試路徑響應
-
-
網絡層次關系
三、搭建模擬環境
1.創建命名空間
kubectl create ns ing-internal
2.安裝ingress ingress-nginx-controller
#下載ingress-nginx-controller.yaml文件
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.6/deploy/static/provider/cloud/deploy.yaml
mv deploy.yaml ingress-nginx-controller.yaml#將yaml文件中的namespace設置變更成題目要求的namespace
apiVersion: v1
kind: Namespace
metadata:labels:app.kubernetes.io/instance: ingress-nginxapp.kubernetes.io/name: ingress-nginxname: ing-internal#然后所有
namespace: ing-internal#將此行注釋掉
externalTrafficPolicy: Local#將service ingress-nginx-controller的type: LoadBalancer將慈航改成ClusterIP才能按照題目要求配置完ingress策略后出現IP
type: ClusterIP ---
#題目中無IngressClass,故將類模塊注釋掉
#apiVersion: networking.k8s.io/v1
#kind: IngressClass
#metadata:
# labels:
# app.kubernetes.io/component: controller
# app.kubernetes.io/instance: ingress-nginx
# app.kubernetes.io/name: ingress-nginx
# app.kubernetes.io/part-of: ingress-nginx
# app.kubernetes.io/version: 1.9.6
# name: nginx
#spec:
# controller: k8s.io/ingress-nginx
---#應用yaml文件,開始安裝
kubectl apply -f ingress-nginx-controller.yaml
3.創建hello.yaml并部署
hello.yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:name: hellonamespace: ing-internallabels:name: hello
spec:replicas: 1selector:matchLabels:name: hellotemplate:metadata:labels:name: hellospec:containers:- name: helloimage: hello-world:2.0ports:- containerPort: 80name: http-web-svc
---
apiVersion: v1
kind: Service
metadata:name: hellonamespace: ing-internal
spec:selector:name: helloports:- name: hello-of-service-portprotocol: TCPport: 5678targetPort: http-web-svc
部署yaml文件
kubectl apply -f hello.yaml
?四、總結
1.題庫主要考察的是Ingress策略,所以必須部署Ingress controller
2.考試環境中是沒有ingressclass的,需要自己創建一個默認類就可以,但是Ingress controller是默認帶了的,為了題目效果要注釋掉。
3.service ingress-nginx-controller的type: LoadBalancer將慈航改成ClusterIP才能按照題目要求配置完ingress策略后出現IP
CKA高仿真環境簡單演示視頻?