-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
120 lines (106 loc) · 3.1 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
version: 2.1
orbs:
aws-ecr: circleci/[email protected]
jobs:
test-app:
docker:
- image: python:3.7.3-stretch
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
make install
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
# run lint!
- run:
name: Run lint
command: |
. venv/bin/activate
make lint
make-image:
docker:
- image: docker:git
working_directory: ~/repo
steps:
- checkout
- setup_remote_docker
- run:
name: Install OS dependencies
command: |
apk update
apk add bash
- run:
name: Test Docker image build
command: |
./run_docker.sh
deploy:
docker:
- image: amazon/aws-cli
steps:
- checkout
- run:
name: Install OS dependencies
command: |
yum -y install tar gzip curl
- run:
name: Install kubectl
command: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
[ -w /usr/local/bin ] && SUDO="" || SUDO=sudo
$SUDO chmod +x ./kubectl
$SUDO mv ./kubectl /usr/local/bin
- run:
name: Install eksctl
command: |
mkdir temp
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C ./temp
[ -w /usr/local/bin ] && SUDO="" || SUDO=sudo
$SUDO chmod +x ./temp/eksctl
$SUDO mv ./temp/eksctl /usr/local/bin
eksctl version
- run:
name: Get k8s cluster
command: |
aws eks update-kubeconfig \
--region ${AWS_DEFAULT_REGION} \
--name longnv43-capstone
- attach_workspace:
at: ~/
- run:
name: Deploy application to EKS cluster
command: |
echo "Kubernetes nodes:"
kubectl get nodes
# ls -la
kubectl apply -f k8s/longnv43-capstone.yml
kubectl get deploy,rs,svc,pods
kubectl rollout restart deployment/longnv43-capstone
kubectl rollout status deployment/longnv43-capstone
workflows:
default:
jobs:
- test-app
- make-image:
requires: [test-app]
- aws-ecr/build-and-push-image:
name: "push-image-to-ecr"
region: ${AWS_DEFAULT_REGION}
repo: ${ECR_REPO_NAME}
tag: latest
requires:
- make-image
- deploy:
requires: [push-image-to-ecr]