2021年10月1日金曜日

EKS for ALB(外部接続編)

参照:
https://docs.aws.amazon.com/ja_jp/eks/latest/userguide/network-load-balancing.html


1)公式から以下のマニュフェストを利用して実施する。


kubectl apply -f nginx.yaml

(赤文字の箇所がALBを認識する際に重要)

=======nginx.yaml=====

apiVersion: apps/v1

kind: Deployment

metadata:

  name: sample-app

spec:

  replicas: 3

  selector:

    matchLabels:

      app: nginx

  template:

    metadata:

      labels:

        app: nginx

    spec:

      containers:

        - name: nginx

          image: public.ecr.aws/nginx/nginx:1.19.6

          ports:

            - name: http

              containerPort: 80

---

apiVersion: v1

kind: Service

metadata:

  name: sample-service

  annotations:

    service.beta.kubernetes.io/aws-load-balancer-type: external

    service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip

    service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing

spec:

  ports:

    - port: 80

      targetPort: 80

      protocol: TCP

  type: LoadBalancer

  selector:

    app: nginx

=================



以下、ELBのマネージメントコンソル上でもALBが追加れたことが確認できる。






以下の作成されたALBにアクセスしてみる





接続が確認を行う









0 件のコメント:

コメントを投稿

terraform(moved.tf)のリソース名の修正方法について

以下の赤枠を直接変えてしまうと、ec2が削除されてしまいます。 これを維持したい場合について記載します。 以下に moved.tf ファイルを作成します。 以下のように、 from に修正前で、 to に修正したい内容を記載します。 以下のリソースにも修正を加えます。 terra...