ingress-nginx 入门转载

原文:https://blog.csdn.net/woshizhangliang999/article/details/108762012

 

部署Ingress-Nginx
该Nginx是经过改造的,而不是传统的Nginx。

Ingress-Nginx官网地址

https://kubernetes.github.io/ingress-nginx/
1
Ingress-Nginx GitHub地址

https://github.com/kubernetes/ingress-nginx

 

 

镜像下载与重命名

docker pull registry.cn-beijing.aliyuncs.com/google_registry/nginx-ingress-controller:0.30.0
docker tag 89ccad40ce8e quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0
docker rmi  registry.cn-beijing.aliyuncs.com/google_registry/nginx-ingress-controller:0.30.0

# 安装 ingress-nginx

# 当前目录
[root@k8s-master ingress]# pwd
/root/k8s_practice/ingress
# 获取NGINX: 0.30.0
[root@k8s-master ingress]# wget https://github.com/kubernetes/ingress-nginx/archive/nginx-0.30.0.tar.gz
[root@k8s-master ingress]# tar xf nginx-0.30.0.tar.gz
# yaml文件在下载包中的位置:ingress-nginx-nginx-0.30.0/deploy/static/mandatory.yaml
[root@k8s-master ingress]# cp -a ingress-nginx-nginx-0.30.0/deploy/static/mandatory.yaml ./
[root@k8s-master ingress]# 
# yaml文件配置修改
[root@k8s-master ingress]# vim mandatory.yaml
………………
apiVersion: apps/v1
kind: DaemonSet   # 从Deployment改为DaemonSet
metadata:
  name: nginx-ingress-controller
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  #replicas: 1   # 注释掉
………………
      nodeSelector:
        kubernetes.io/hostname: k8s-master   # 修改处
      # 如下几行为新加行  作用【允许在master节点运行】
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
………………
          ports:
            - name: http
              containerPort: 80
              hostPort: 80    # 添加处【可在宿主机通过该端口访问Pod】
              protocol: TCP
            - name: https
              containerPort: 443
              hostPort: 443   # 添加处【可在宿主机通过该端口访问Pod】
              protocol: TCP
………………
[root@k8s-master ingress]# 
[root@k8s-master ingress]# kubectl apply -f mandatory.yaml
namespace/ingress-nginx created
configmap/nginx-configuration created
configmap/tcp-services created
configmap/udp-services created
serviceaccount/nginx-ingress-serviceaccount created
clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created
role.rbac.authorization.k8s.io/nginx-ingress-role created
rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created
clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created
daemonset.apps/nginx-ingress-controller created
limitrange/ingress-nginx created
[root@k8s-master ingress]# 
[root@k8s-master ingress]# kubectl get ds -n ingress-nginx -o wide
NAME                       DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                       AGE     CONTAINERS                 IMAGES                                                                  SELECTOR
nginx-ingress-controller   1         1         1       1            1           kubernetes.io/hostname=k8s-master   9m47s   nginx-ingress-controller   quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0   app.kubernetes.io/name=ingress-nginx,app.kubernetes.io/part-of=ingress-nginx
[root@k8s-master ingress]# 
[root@k8s-master ingress]# kubectl get pod -n ingress-nginx -o wide
NAME                             READY   STATUS    RESTARTS   AGE     IP            NODE         NOMINATED NODE   READINESS GATES
nginx-ingress-controller-rrbh9   1/1     Running   0          9m55s   10.244.0.46   k8s-master              


————————————————
版权声明:本文为CSDN博主「LightZhang666」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/woshizhangliang999/article/details/108762012

————————————————
版权声明:本文为CSDN博主「LightZhang666」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/woshizhangliang999/article/details/108762012

你可能感兴趣的:(kubernetes)