Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

EKS上でELBを動かす

More than 1 year has passed since last update.

Nginxが複数起動するDeployment

sample-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sample-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: sample-app
  template:
    metadata:
      labels:
        app: sample-app
    spec:
      containers:
        - name: nginx-container
          image: nginx:1.12
          ports:
            - containerPort: 80

デプロイ

kubectl apply -f sample-deployment.yaml

確認

~/Desktop ❯❯❯ kubectl get pod | grep sample-deployment
sample-deployment-6cd85bd5f-48pp4   1/1     Running            0          39s
sample-deployment-6cd85bd5f-swkq8   1/1     Running            0          39s
sample-deployment-6cd85bd5f-zl9sh   1/1     Running            0          39s

ロードバランサー用サービス

sample-lb.yaml
apiVersion: v1
kind: Service
metadata:
  name: aws-lb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
  labels:
    app: sample-app
spec:
  type: LoadBalancer
  ports:
    - name: "http-port"
      protocol: "TCP"
      port: 80
      targetPort: 80
  selector:
    app: sample-app

デプロイ

kubectl apply -f sample-lb.yaml

確認

k get service aws-lb

出力結果

NAME     TYPE           CLUSTER-IP   EXTERNAL-IP                                                                     PORT(S)        AGE
aws-lb   LoadBalancer   10.100.0.6   adef5be59fa4111e9919f0251c115a68-cc4f6a95cee97702.elb.us-east-1.amazonaws.com   80:30859/TCP   59s

image.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away