Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
はじめての CircleCI × EKS
Search
enta0701
January 25, 2019
720
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
はじめての CircleCI × EKS
enta0701
January 25, 2019
Transcript
21 slides
はじめての CircleCI × EKS Created by @endotakuya
話すこと CircleCI 経由 で EKS へデプロイする方法 環境変数の取り扱い ALB の DNS
名でアクセスする設定
話さないこと Kubernetes の概念や用語 Kubernetes の各種設定 CircleCI v2 の 詳細設定 ECR
の使い方
CircleCI 経由 で EKS へデプロイ
前提 / 準備 Rails Application MySQL Nginx 各コンテナの Docker イメージが作れる(Build
できる)こと。
CirlceCI AWS の各リソースへの操作は awscli を使用 ... deploy: &deploy <<: *defaults
docker: - image: circleci/python:3.5 - run: name: Install the AWS CLI command: | sudo pip install --upgrade pip sudo pip install awscli==1.16.89 - run: # build / push - run: # deploy ...
CirlceCI ― Docker イメージ の Build/Push shell script でごりごり。 #
Docker Login eval $(aws ecr get-login --region ap-northeast-1 --no-include-email) # Docker image # app app=xxxx.dkr.ecr.ap-northeast-1.amazonaws.com/example/app:$CIRCLE_SHA1 docker build -t $app -f .docker/app/Dockerfile . docker push $app # web ...
CirlceCI ― Deploy 1. 必要なコマンドをインストール 2. 対象のクラスタをセット # Install kubectl
... # Install aws-iam-authenticator ... # Set cluster aws eks update-kubeconfig --name $AWS_EKS_CLUSTER_NAME kubectl config use-context $AWS_EKS_CLUSTER_ARN
CirlceCI ― Deploy envsubst により、環境変数を設定ファイルの k8s の yaml に埋め込む #
Deploy sudo apt-get update && sudo apt-get install -y gettext-base k8s_resource_path=./.docker/.k8s for file in $k8s_resource_path/*.yaml; do envsubst < $file | kubectl apply -f - done これで、External IP が発行されればOK ※ k8s の設定ファイルは BananaCI の設定とほとんど同じです
環境変数の取り扱い
CirlceCI での環境変数 恐らくリポジトリで設定してるはず
本番 / ステージングはどうする?
CircleCI Contexts Organization や Account 単位で環境変数郡を作成することができる
CircleCI Contexts (ex.) example-production AWS_EKS_CLUSTER_NAME RAILS_ENV MYSQL_HOST example-staging AWS_EKS_CLUSTER_NAME RAILS_ENV
MYSQL_HOST
CircleCI Contexts の呼び出し方 work ow の job 呼び出し時に指定する workflows: version:
2 build_and_deploy: jobs: - deploy-staging: context: example-staging - deploy-production: context: example-production filters: branches: only: - release
ALB の DNS 名でアクセスする設定
Ingress L7 層レベル(http/https のパスベースで負荷分散ができる)で Service を介して、クラスタを外部とつなぐ apiVersion: extensions/v1beta1 kind: Ingress
metadata: name: example-ingress spec: rules: - http: paths: - path: /* backend: serviceName: example-svc # Service 名 servicePort: 80
ALB Ingress Controller kubernetes-sigs/aws-alb-ingress-controller ingress を作成したタイミングで ALB やターゲットグループを作成 セキュリティグループやサブネットを自動検出して関連付け 対象クラスタやアクセキーを設定するだけ
$ kubectl apply -f alb-rbac-role.yaml
RBAC Role-Based Access Control クラスタの操作権限や内部の Kubernetes API の操作ユーザーを限定 alb-ingress-controller は、一般ユーザが容易に触れないほうがいいの
で、操作を限定したユーザーを作成 https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress- controller/v1.0.0/docs/examples/rbac-role.yaml $ kubectl apply -f alb-rbac-role.yaml
ALB の DNS 名を叩けば…
ね?簡単でしょ?
More Decks by enta0701
See All by enta0701
ミルクココアが好きです
endotakuya
0
80
Kubernetes 超入門
endotakuya
0
170
GKE と EKS について 理解した気分になる7分間
endotakuya
0
89
Go / Node.js で入門する gRPC
endotakuya
0
220
LINE Clova スキルの開発ハンズオンに enebular は最適だった話。
endotakuya
1
1.1k
LINE Clova と自由に会話をしよう
endotakuya
0
200
GoでClova Extension開発ができるようになりました
endotakuya
0
90
シンプルなテンプレートエンジンが欲しい
endotakuya
0
850
Alfred Workflows by Go
endotakuya
4
5.5k
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
480
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
750
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
640
Paper Plane
katiecoart
PRO
6
55k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Writing Fast Ruby
sferik
630
63k
Typedesign – Prime Four
hannesfritz
42
3.2k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
840
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
540
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
Abbi's Birthday
coloredviolet
5
11k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k