部署ingress-nginx

ingress-nginx

ingress 官方網(wǎng)站
ingress 倉(cāng)庫(kù)地址
ingress-nginx v1.1 最新版本 v1.1
適用于Kubernetes 版本 v1.19+ (也包括 v1.19 )
Kubernetes-v1.22+ 需要使用 ingress-nginx>=1.0,因?yàn)?networking.k8s.io/v1beta 已經(jīng)移除

直接部署 ingress-nginx

直接部署比較簡(jiǎn)單,直接拉去 github 的文件就可以了,如果遇到長(zhǎng)時(shí)間無(wú)響應(yīng),可以終止任務(wù)從新拉取。
拉取鏡像部分,可以修改為一下的鏡像地址

$ wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/baremetal/deploy.yaml
$ sed -i 's@k8s.gcr.io/ingress-nginx/controller:v1.1.0\(.*\)@willdockerhub/ingress-nginx-controller:v1.1.0@' deploy.yaml
$ sed -i 's@k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1\(.*\)$@hzde0128/kube-webhook-certgen:v1.1@' deploy.yaml
$ kubectl apply -f ingress-nginx.yaml

檢查ingress-nginx 狀態(tài)

$ kubectl get pods -n ingress-nginx
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-shjt6        0/1     Completed   0          107m
ingress-nginx-admission-patch-qt2cv         0/1     Completed   0          107m
ingress-nginx-controller-689b7bb46c-j5stp   1/1     Running     0          107m

$  kubectl get svc -n ingress-nginx
NAME                                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.96.186.13   <none>        80:32081/TCP,443:32540/TCP   107m
ingress-nginx-controller-admission   ClusterIP   10.96.55.31    <none>        443/TCP                      107m

測(cè)試部署ingress-nginx

# vim  nginx-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: nginx.test.com
    http:
      paths:
      - path: "/"
        pathType: Prefix
        backend:
          service:
            name: nginx
            port:
              number: 80
#聲明部署nginx-ingress
$ kubectl  apply  -f  nginx-ingress.yaml
#查看ingress-nginx 節(jié)點(diǎn)對(duì)應(yīng)的端口
$ kubectl get svc -n ingress-nginx
NAME                                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.96.186.13   <none>        80:32081/TCP,443:32540/TCP   107m
ingress-nginx-controller-admission   ClusterIP   10.96.55.31    <none>        443/TCP                      107m

訪問ingress映射的域名暴露的端口

 # curl nginx.test.com:32081
<!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 >nginx.org</a>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
image.png
image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容