-
Notifications
You must be signed in to change notification settings - Fork 4
199 lines (168 loc) · 5.46 KB
/
deploy.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: deploy
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_TAG: ghcr.io/${{ github.repository }}
KUBECTL_VERSION: v1.27.1
jobs:
oteldb:
environment: prod
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
KUBECONFIG: /tmp/kubeconfig
# Skip deploy commit message contains #skip
if: ${{ !contains(github.event.head_commit.message, '!skip') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
cache: false
- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
echo "goversion=$(go env GOVERSION)" >> $GITHUB_ENV
- name: Set up cache
uses: actions/cache@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: deploy-${{ runner.os }}-go-${{ env.goversion }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
deploy-${{ runner.os }}-go-${{ env.goversion }}
- name: Docker log in
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short commit SHA
id: var
shell: bash
run: |
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Go build
env:
CGO_ENABLED: 0
run: |
go build -v ./cmd/oteldb
go build -v ./cmd/otelproxy
go build -v ./cmd/otelfaker
go build -v ./cmd/chotel
- name: Base image
uses: docker/build-push-action@v5
with:
context: .
file: deploy.Dockerfile
push: true
tags: "${{ env.IMAGE_TAG }}:${{ env.sha }}"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Proxy image
uses: docker/build-push-action@v5
with:
context: .
file: deploy.proxy.Dockerfile
push: true
tags: "${{ env.IMAGE_TAG }}/proxy:${{ env.sha }}"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Faker image
uses: docker/build-push-action@v5
with:
context: .
file: deploy.faker.Dockerfile
push: true
tags: "${{ env.IMAGE_TAG }}/faker:${{ env.sha }}"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: ClickHouse OTEL Exporter Image
uses: docker/build-push-action@v5
with:
context: .
file: deploy.chotel.Dockerfile
push: true
tags: "${{ env.IMAGE_TAG }}/chotel:${{ env.sha }}"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate deployment with SHA version
run: sed 's/:main/:${{ env.sha }}/g' .k8s/deployment.yml > .k8s/deployment.deploy.yml
- name: Set up kubectl cache
uses: actions/cache@v3
with:
path: /tmp/kubectl
key: kubectl-${{ env.KUBECTL_VERSION }}
- name: Check kubectl
id: "kubectl"
uses: andstor/file-existence-action@v2
with:
files: /tmp/kubectl
- name: Download kubectl
if: steps.kubectl.outputs.files_exists != 'true'
run: |
wget -O /tmp/kubectl "https://dl.k8s.io/release/${{ env.KUBECTL_VERSION }}/bin/linux/amd64/kubectl"
chmod +x /tmp/kubectl
- name: Setup kubeconfig
env:
KUBE: ${{ secrets.KUBE }}
run: .k8s/kubeconfig.sh
- name: Deploy
run: |
/tmp/kubectl apply -f .k8s/deployment.deploy.yml -f .k8s/service.yaml
/tmp/kubectl -n faster rollout status deployment oteldb otelproxy --timeout=1m
otel:
environment: prod
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
KUBECONFIG: /tmp/kubeconfig
# Skip deploy commit message contains #skip
if: ${{ !contains(github.event.head_commit.message, '!skip') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Docker log in
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up kubectl cache
uses: actions/cache@v3
with:
path: /tmp/kubectl
key: kubectl-${{ env.KUBECTL_VERSION }}
- name: Check kubectl
id: "kubectl"
uses: andstor/file-existence-action@v2
with:
files: /tmp/kubectl
- name: Download kubectl
if: steps.kubectl.outputs.files_exists != 'true'
run: |
wget -O /tmp/kubectl "https://dl.k8s.io/release/${{ env.KUBECTL_VERSION }}/bin/linux/amd64/kubectl"
chmod +x /tmp/kubectl
- name: Setup kubeconfig
env:
KUBE: ${{ secrets.KUBE }}
run: .k8s/kubeconfig.sh
- name: Deploy
run: |
/tmp/kubectl -n monitoring apply -f .k8s/otel.yml
/tmp/kubectl -n monitoring rollout status --timeout=1m deployment otel-collector
/tmp/kubectl -n monitoring rollout status --timeout=1m daemonset otel-agent