8.3 NGINXコントローラのインストール

NGINXコントローラをインストールするには:
  1. $WORKDIR/kubernetes/helm14c/に移動し、次を含むnginx-ingress-values-override.yamlを作成します:

    ノート:

    次の構成では:
    • ネームスペースoudsmnsのデプロイメント/リリース名として値oudsmを含むoudsmがインストールされていると想定しています。別のデプロイメント名またはネームスペース(あるいはその両方)を使用する場合は、適切に変更してください。
    • LoadBalancerを使用してイングレスがデプロイされます。NodePortを使用する場合は、構成を適切に変更してください。NGINX構成の詳細は、NGINXイングレス・コントローラに関する項を参照してください。
    controller:
      admissionWebhooks:
        enabled: false
      extraArgs:
        # The secret referred to by this flag contains the default certificate to be used when accessing the catch-all server.
        # If this flag is not provided NGINX will use a self-signed certificate.
        # If the TLS Secret is in different namespace, name can be mentioned as <namespace>/<tlsSecretName>
        default-ssl-certificate: oudsmns/oudsm-tls-cert
      service:
        # controller service external IP addresses
        # externalIPs:
        #  - < External IP Address >
        # To configure Ingress Controller Service as LoadBalancer type of Service
        # Based on the Kubernetes configuration, External LoadBalancer would be linked to the Ingress Controller Service
        type: LoadBalancer
        # Configuration for NodePort to be used for Ports exposed through Ingress
        # If NodePorts are not defined/configured, Node Port would be assigned automatically by Kubernetes
        # These NodePorts are helpful while accessing services directly through Ingress and without having External Load Balancer.
        nodePorts:
          # For HTTP Interface exposed through LoadBalancer/Ingress
          http: 30080
          # For HTTPS Interface exposed through LoadBalancer/Ingress
          https: 30443
    

    ノート:

    Kubernetes構成用に構成された外部ロード・バランサがない場合は、type: LoadBalancertype: NodePortに変更します。
  2. NGINXイングレスをインストールおよび構成するには、次のコマンドを発行します:
    cd $WORKDIR/kubernetes/helm14c/
    helm install --namespace <namespace> \
    --values nginx-ingress-values-override.yaml \
    lbr-nginx stable/ingress-nginx \
    --version 4.7.2
    説明:
    • lbr-nginxは、デプロイメント名です
    • stable/ingress-nginxは、チャート参照です
    例:
    cd $WORKDIR/kubernetes/helm14c/
    helm install --namespace mynginxns \
    --values nginx-ingress-values-override.yaml \
    lbr-nginx stable/ingress-nginx \
    --version 4.7.2
    出力は次のようになります:
    NAME: lbr-nginx
    LAST DEPLOYED: <DATE>
    NAMESPACE: mynginxns
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    NOTES:
    The ingress-nginx controller has been installed.
    It may take a few minutes for the LoadBalancer IP to be available.
    You can watch the status by running 'kubectl --namespace mynginxns get services -o wide -w lbr-nginx-ingress-nginx-controller'
      
    An example Ingress that makes use of the controller:
      apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
        name: example
        namespace: foo
      spec:
        ingressClassName: nginx
        rules:
          - host: www.example.com
            http:
              paths:
                - pathType: Prefix
                  backend:
                    service:
                      name: exampleService
                      port:
                        number: 80
                  path: /
        # This section is only required if TLS is to be enabled for the Ingress
        tls:
          - hosts:
            - www.example.com
            secretName: example-tls
    
    If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
    
      apiVersion: v1
      kind: Secret
      metadata:
        name: example-tls
        namespace: foo
      data:
        tls.crt: <base64 encoded cert>
        tls.key: <base64 encoded key>
      type: kubernetes.io/tls