ingress-nginx快速安装
ingress-nginx的安装
基本概要
-
集群信息
-
准备配置文件
-
部署服务
1.0 集群基本信息
master 192.168.211.130
node01 192.168.211.131
node02 192.168.211.132
[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
1. 1 准备好配置文件
安装ingress的yaml文件[此文件已经修改好了,无需修改其他的地方,直接使用]
此文件这里命名为: ingress-controller-1.1.yaml
wget https://gitee.com/CloudLemon/tekton-install/raw/master/ingress-argocd/ingress-nginx.yaml
2. 0 安装ingress
# 给需要安装的节点打上标签, 如果只安装一个就 ,就给你需要的节点 打上标签就行
kubectl label node master isIngress="true"
kubectl label node node01 isIngress="true"
kubectl label node node02 isIngress="true"
# 安装
kubectl apply -f ingress-controller-1.1.yaml
3、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
如果遇到如下错误,请尝试如下解决方案
1、检查物理机80和443端口有没有被占用!!!!!
2、检查secret名字
2.1、节点是否被禁止调度
3.0 验证结果
[root@k8s-master1 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
gateway NodePort 10.0.0.193 <none> 80:32457/TCP 15d
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 33d
nginx-service NodePort 10.233.21.221 <none> 80/TCP 38m
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
annotations:
spec:
ingressClassName: nginx
rules:
- host: myservicea.foo.org
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 myservicea.foo.org 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
192.168.211.130 master
192.168.211.131 node01
192.168.211.132 node02
192.168.211.131 myservicea.foo.org