OKE安装NginxIngress配置应用TLS证书
- IT业界
- 2025-09-13 23:03:01

OKE 安装 Nginx Ingress && 配置应用 TLS 证书 1 安装 Nginx Ingress controller
示例:
kubectl apply -f raw.githubusercontent /kubernetes/ingress-nginx/controller-v<vnum>/deploy/static/provider/cloud/deploy.yaml 其中 是ingress的版本,大家可以参考 nginx ingress 官方找寻自己的示例nginx ingress 官方地址: github /kubernetes/ingress-nginx?tab=readme-ov-file#supported-versions-table
2 安装后查看 ingress 2.1 查看svc创建状态 kubectl get svc -n ingress-nginx 2.2 结果展示当前状态表示正在创建中,EXTERNAL-IP 的pending状态表示 OKE 正在为当前svc分配负载均衡 IP
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller LoadBalancer 10.96.229.38 <pending> 80:30756/TCP,443:30118/TCP 1h 2.3 持续展示如下结果中 EXTERNAL-IP 列已经显示出 IP, 表示当前 ingress 已经完成了映射
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller LoadBalancer 10.96.229.38 129.146.214.219 80:30756/TCP,443:30118/TCP 1h 3 创建 TLS Secret 3.1 自签名方式创建KEY示例采用自签名方式进行配置
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=nginxsvc/O=nginxsvc" 3.2 TLS 添加 Secret 中 kubectl create secret tls tls-secret --key tls.key --cert tls.crt 4 创建示例后端集 4.1 创建 Deployment hello-world 示例 ### vim hello-world-ingress.yaml apiVersion: apps/v1 kind: Deployment metadata: name: docker-hello-world labels: app: docker-hello-world spec: selector: matchLabels: app: docker-hello-world replicas: 3 template: metadata: labels: app: docker-hello-world spec: containers: - name: docker-hello-world image: scottsbaldwin/docker-hello-world:latest ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: docker-hello-world-svc spec: selector: app: docker-hello-world ports: - port: 8088 targetPort: 80 type: ClusterIP 4.2 部署示例 kubectl create -f hello-world-ingress.yaml 5 配置 Ingress 分发 5.1 配置 ingress .yaml ### vim ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-world-ing spec: ingressClassName: nginx tls: - secretName: tls-secret rules: - http: paths: - path: / pathType: Prefix backend: service: name: docker-hello-world-svc port: number: 8088 5.2 应用 ingress 配置 kubectl create -f ingress.yaml 6 测试结果 $ curl -k 129.146.214.219 <h1>Hello webhook world from: docker-hello-world-1732906117-6115l</h1> $ curl -k 129.146.214.219 <h1>Hello webhook world from: docker-hello-world-1732906117-7r89v</h1> $ curl -k 129.146.214.219 <h1>Hello webhook world from: docker-hello-world-1732906117-0ztkm</h1> 7 参考资料docs.oracle /en-us/iaas/Content/ContEng/Tasks/contengsettingupingresscontroller.htm#Example_Setting_Up_an_Ingress_Controller_on_a_Cluster
OKE安装NginxIngress配置应用TLS证书由讯客互联IT业界栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“OKE安装NginxIngress配置应用TLS证书”
上一篇
数据库二三事(9)
下一篇
【PTA】1019数字黑洞