最新消息:时间抓起来说是金子,抓不住就是流水。

Ingress-nginx 安装

Kubernetes 老子黑牵翻 1084浏览 0评论

1、集群基本信息

master 10.0.0.90
node01 10.0.0.91
node02 10.0.0.92
[root@master yaml]# kubectl get node
NAME     STATUS   ROLES                  AGE     VERSION
master   Ready    control-plane,master   4d22h   v1.23.8
node01   Ready    worker                 4d22h   v1.23.8
node02   Ready    worker                 4d22h   v1.23.8

2、ingress-nginx.yml文件下载
安装ingress的yaml文件[此文件已经修改好了,无需修改其他的地方,直接使用]
此文件这里命名为: ingress-controller-1.1.yaml

[root@k8s-master1 ~]# wget http://soft.ileiming.com/k8s/ingress-nginx.yaml
[root@k8s-master1 ~]# mv ingress-nginx.yaml ingress-controller-1.1.yaml

3、安装ingree-nginx

# 给需要安装的节点打上标签, 如果只安装一个就 ,就给你需要的节点 打上标签就行
[root@k8s-master1 ~]# kubectl label node master isIngress="true"
[root@k8s-master1 ~]# kubectl label node node01 isIngress="true"
[root@k8s-master1 ~]# kubectl label node node02 isIngress="true"

# 安装
[root@k8s-master1 ~]# kubectl apply -f ingress-controller-1.1.yaml

[root@k8s-master1 ~]# kubectl get pod -n ingress-nginx
NAME                                   READY   STATUS      RESTARTS      AGE
ingress-nginx-admission-create-dwm6c   0/1     Completed   0             39m
ingress-nginx-admission-patch-nf5sp    0/1     Completed   1             39m
ingress-nginx-controller-6hgb8         1/1     Running     7 (33m ago)   39m
ingress-nginx-controller-7mxrq         1/1     Running     0             39m
ingress-nginx-controller-8q9cq         1/1     Running     0             39m

4、验证结果

[root@k8s-master1 ~]# kubectl get svc
NAME            TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
gateway         NodePort    10.0.0.193           80:32457/TCP   15d
kubernetes      ClusterIP   10.0.0.1             443/TCP        33d
nginx-service   NodePort    10.233.21.221        80/TCP    38m
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
spec:
  ingressClassName: nginx
  rules:
  - host: test.ileiming.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-service
            port:
              number: 80
[root@master yaml]# kubectl get ingress
NAME      CLASS   HOSTS                ADDRESS           PORTS   AGE
ingress   nginx   test.ileiming.com   192.168.211.131   80      117m
[root@master yaml]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.90  master
10.0.0.91  node01
10.0.0.92  node02

10.0.0.92 test.ileiming.com

转载请注明:LINUX服务器运维架构技术分享 » Ingress-nginx 安装

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址