码迷,mamicode.com
首页 > Web开发 > 详细

kubenetes install ingress-nginx

时间:2020-07-26 19:30:25      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:done   tar   rpo   内容   创建   art   time   pull   component   

查看kubectl services简称列表
kubectl api-resources
 查看ingress-nginx是否在安装
$ kubectl get pods -n ingress-nginx
NAME                                       READY     STATUS    RESTARTS   AGE
ingress-nginx-controller-fdcdcd6dd-vvpgs   1/1       Running   0          11s
查看资源创建文件

$ kubectl describe pods ingress-nginx-controller-c96557986-q4f4z -n ingress-nginx

Name: ingress-nginx-controller-c96557986-q4f4z
Namespace: ingress-nginx
Priority: 0
Node: node2/192.168.147.130
Start Time: Sun, 26 Jul 2020 17:04:47 +0800
Labels: app.kubernetes.io/component=controller
app.kubernetes.io/instance=ingress-nginx
app.kubernetes.io/name=ingress-nginx
pod-template-hash=c96557986
Annotations: cni.projectcalico.org/podIP: 10.244.1.33/32
Status: Pending
IP: 10.244.1.33

 

删除ingress-nginx相关对象

$ kubectl delete pod ingress-nginx-controller-c96557986-q4f4z -n ingress-nginx

pod "ingress-nginx-controller-c96557986-q4f4z" deleted

 

ingress-nginx 在kubernetes中实现了传统nginx的url区分,同时又实现了动态更新配置的功能

可以到https://github.com/kubernetes/ingress-nginx/tree/nginx-0.20.0/deploy,下载相应的安装包,使用kubectl apply -f 加载相关模块

for file in configmap.yaml namespace.yaml rbac.yaml with-rbac.yaml tcp-services-configmap.yaml default-backend.yaml  ; \
do wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/$file;done

 注意:

     因为新版本的已经变更来位置,或者一些yaml包已经不存在,需要根据自己的需要挑选yaml文件,可选的版本如下:

   https://github.com/kubernetes/ingress-nginx/blob/nginx-0.25.1/deploy/static

   https://github.com/kubernetes/ingress-nginx/blob/nginx-0.20.0/deploy/

  https://github.com/kubernetes/ingress-nginx/blob/nginx-0.24.1/deploy/

   如果实在没办法下载,就用笨办法,一个一个的把内容拷贝下来

  新版本对apiversion的支持有所变更,一些yaml文件的apiVersion需要调整

  如with-rabc.yaml default-backend.yaml 需要把extension/v1beta1,改成apps/v1

   ###  如果想使用最新的版本,则需要从官网下载最新版的安装脚本,最新版集合到了一个deploy.yaml文件中

 

发现半天来还是没成功,仔细查看发现事国外的连接不上啊

[root@master mytest]# kubectl get pods -n ingress-nginx
NAME                                       READY   STATUS             RESTARTS   AGE
ingress-nginx-admission-create-8x67h       0/1     Completed          0          44m
ingress-nginx-controller-c96557986-j62fk   0/1     ImagePullBackOff   0          21m
nginx-ingress-controller-9c56c5c84-s9hsh   1/1     Running            0          70m  

解决办法

修改mandatory.yaml配置文件
1.搜索 serviceAccountName,跳转到此处
2.修改配置

sed -i ‘s#quay.io/kubernetes-ingress-controller/nginx-ingress-controller#registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller#g‘ deploy.yaml

 

准备相关安装环境,先准备pod和service

apiVersion: v1
kind: Service
metadata:
  name: myapp
  namespace: default
spec:
  selector:
    app: myapp
    release: canary
  clusterIP: "None"
  ports:
  - name: http
    targetPort: 80
    port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deploy
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
       app: myapp
       release: canary
  template:
     metadata:
       labels:
         app: myapp
         release: canary
     spec:
        containers:
        - name: myapp
          image: tomcat
          ports:
          - name: http
            containerPort: 80  

 

 

  

  

kubenetes install ingress-nginx

标签:done   tar   rpo   内容   创建   art   time   pull   component   

原文地址:https://www.cnblogs.com/mjxi/p/13381314.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!