zoukankan      html  css  js  c++  java
  • helm安装ingress

    helm安装ingress

    一、安装Helm

    # wget https://get.helm.sh/helm-v3.3.4-linux-amd64.tar.gz
    ​
    # tart -zxvf helm-v3.3.4-linux-amd64.tar.gz 
    ​
    # mv linux-amd64/helm /usr/local/bin/helm
    ​
    # helm version
    version.BuildInfo{Version:"v3.3.4", GitCommit:"a61ce5633af99708171414353ed49547cf05013d", GitTreeState:"clean", GoVersion:"go1.14.9"}
    

       

    二、下载ingress

    # mkdir ingress && cd ingress
    # 新建仓库
    # helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
    ​
    # helm pull ingress ingress-nginx/ingress-nginx
    # tar -xf ingress-nginx-3.7.1.tgz && cd ingress-nginx
    

      

    三、安装ingress

    1. 修改values.yaml

     

    # 修改controller镜像地址
    repository: registry.cn-beijing.aliyuncs.com/dotbalo/controller
    ​
    # dnsPolicy
    dnsPolicy: ClusterFirstWithHostNet
    ​
    # 使用hostNetwork,即使用宿主机上的端口80 443
    hostNetwork: true
    ​
    # 使用DaemonSet,将ingress部署在指定节点上
    kind: DaemonSet
    ​
    # 节点选择,将需要部署的节点打上ingress=true的label
      nodeSelector:
        kubernetes.io/os: linux
        ingress: "true"
        
    # 修改type,改为ClusterIP。如果在云环境,有loadbanace可以使用loadbanace
    type: ClusterIP
    ​
    # 修改kube-webhook-certgen镜像地址
    registry.cn-beijing.aliyuncs.com/dotbalo/kube-webhook-certgen
    

      

    2. 安装ingress

    # 选择节点打label
    # kubectl label node node01 ingress=true
    ​
    # 创建一个ingress的namespace
    # kubectl create ns ingress-nginx
    ​
    # 创建ingress
    # helm install ingress-nginx -n ingress-nginx
    ​
    # kubectl get pods -n ingress-nginx -owide
    NAME                             READY   STATUS    RESTARTS   AGE   IP               NODE     NOMINATED NODE   READINESS GATES
    ingress-nginx-controller-mrb2t   1/1     Running   0          15h   192.168.10.243   node01   <none>           <none>
     
    

      

    四、使用ingress

    1. Ingress配置文件

      ingress-example.yaml
      
      apiVersion: networking.k8s.io/v1beta1
      kind: Ingress
      metadata:
        name: example-ingress
        annotations:
          kubernetes.io/ingressClass: "nginx"
      spec:
        rules:
        - host: foo.bar.com
          http:
            paths:
            - path: /
              backend:
                serviceName: nginx-svc
                servicePort: 80
      

        

      kubernetes.io/ingressClass: "nginx":使用ingressClass: "nginx",告诉ingress实现的配置

      rules: 一个rules可以有多个host

      host : 访问ingress的域名

      path : 类似于nginx的location配置,同一个host可以配置多个path

      backend:描述Service和ServicePort的组合。对ingress匹配主机和路径的HTTP与HTTPS请求将被转发到后端Pod

       

    2. 创建一个nginx的Deployment

      apiVersion: v1
      kind: Service
      metadata:
        name: nginx-svc
        labels:
          app: nginx-svc
      spec:
        selector:
          app: nginx
        ports:
        - name: http
          protocol: TCP
          port: 80
          targetPort: 80
      ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        annotations:
          deployment.kubernetes.io/revision: "1"
        labels:
          app: nginx
        name: nginx
        namespace: default
      spec:
        progressDeadlineSeconds: 600
        replicas: 2 #副本数
        revisionHistoryLimit: 10 # 历史记录保留的个数
        selector:
          matchLabels:
            app: nginx
        strategy:
          rollingUpdate:
            maxSurge: 25%
            maxUnavailable: 25%
          type: RollingUpdate
        template:
          metadata:
            labels:
              app: nginx
          spec:
            containers:
            - image: nginx:1.15.2
              imagePullPolicy: IfNotPresent
              name: nginx
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
            restartPolicy: Always
            terminationGracePeriodSeconds: 30
      ​

       

    3. 创建

      # kubectl create -f ingress-example.yaml 
      Warning: networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
      ingress.networking.k8s.io/example-ingress created
      

        

      查看ingress

      # kubectl get ingress
      Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
      NAME              CLASS    HOSTS         ADDRESS         PORTS   AGE
      example-ingress   <none>   foo.bar.com   10.101.32.165   80      107s
      

         

    4. 修改本机hosts文件,访问far.bar.com

     

     

  • 相关阅读:
    storm源码分析之topology提交过程
    storm启动supervisor源码分析-supervisor.clj
    storm启动nimbus源码分析-nimbus.clj
    storm shell命令源码分析-shell_submission.clj
    storm定时器timer源码分析-timer.clj
    Storm在zookeeper上的目录结构
    storm操作zookeeper源码分析-cluster.clj
    Four subspaces
    拉格朗日量(函数)、达朗贝尔原理、哈密顿量
    离散正弦信号的周期
  • 原文地址:https://www.cnblogs.com/bigberg/p/13926052.html
Copyright © 2011-2022 走看看