Skip to content

Commit cf0c3ae

Browse files
Alexander Matyushentsevmarcb1
authored andcommitted
Refactor Dockerfile; create k8s deployment manifests
1 parent 915a61d commit cf0c3ae

File tree

10 files changed

+228
-50
lines changed

10 files changed

+228
-50
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.git
3+
Dockerfile

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG ARGOCD_VERSION=v0.12.1
2+
FROM argoproj/argocd:$ARGOCD_VERSION as argocd
3+
4+
FROM node:11.10.1-slim
5+
6+
RUN apt-get update && apt-get install -y \
7+
git && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
10+
11+
WORKDIR /home/argocd/argocd-bot
12+
ADD ["package.json", "package-lock.json", "./"]
13+
14+
RUN npm install
15+
16+
ADD [".", "./"]
17+
18+
COPY --from=argocd /usr/local/bin/argocd /usr/local/bin/argocd
19+
COPY --from=argocd /usr/local/bin/helm /usr/local/bin/helm
20+
COPY --from=argocd /usr/local/bin/kustomize /usr/local/bin/kustomize
21+
COPY --from=argocd /usr/local/bin/kustomize1 /usr/local/bin/kustomize1
22+
COPY --from=argocd /usr/local/bin/ks /usr/local/bin/ks
23+
24+
RUN groupadd -g 999 argocd && \
25+
useradd -r -u 999 -g argocd argocd && \
26+
chown argocd:argocd /home/argocd && \
27+
chown argocd:argocd /home/argocd/argocd-bot
28+
#workaround https://github.com/golang/go/issues/14625
29+
ENV USER=argocd
30+
USER argocd

deployment/Dockerfile

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: argocd-bot
6+
name: argocd-bot
7+
spec:
8+
selector:
9+
matchLabels:
10+
app.kubernetes.io/name: argocd-bot
11+
template:
12+
metadata:
13+
labels:
14+
app.kubernetes.io/name: argocd-bot
15+
spec:
16+
containers:
17+
- name: argocd-bot
18+
command: [npm, start]
19+
image: argocd-bot:latest
20+
env:
21+
- name: NODE_TLS_REJECT_UNAUTHORIZED
22+
value: "0"
23+
- name: PRIVATE_KEY_PATH
24+
value: "/data/key.pem"
25+
- name: ARGO_CD_SERVER_IP
26+
valueFrom:
27+
secretKeyRef:
28+
name: argocd-bot-secret
29+
key: ARGOCD_SERVER
30+
- name: ARGOCD_SERVER
31+
valueFrom:
32+
secretKeyRef:
33+
name: argocd-bot-secret
34+
key: ARGOCD_SERVER
35+
- name: ARGO_CD_API_TOKEN
36+
valueFrom:
37+
secretKeyRef:
38+
name: argocd-bot-secret
39+
key: TOKEN
40+
- name: ARGOCD_AUTH_TOKEN
41+
valueFrom:
42+
secretKeyRef:
43+
name: argocd-bot-secret
44+
key: TOKEN
45+
- name: APP_ID
46+
valueFrom:
47+
secretKeyRef:
48+
name: argocd-bot-secret
49+
key: APP_ID
50+
- name: GITHUB_TOKEN
51+
valueFrom:
52+
secretKeyRef:
53+
name: argocd-bot-secret
54+
key: GITHUB_TOKEN
55+
- name: GITHUB_REPO
56+
valueFrom:
57+
secretKeyRef:
58+
name: argocd-bot-secret
59+
key: GITHUB_REPO
60+
- name: WEBHOOK_SECRET
61+
valueFrom:
62+
secretKeyRef:
63+
name: argocd-bot-secret
64+
key: WEBHOOK_SECRET
65+
volumeMounts:
66+
- name: app-private-key
67+
mountPath: "/data"
68+
readOnly: true
69+
imagePullPolicy: Always
70+
ports:
71+
- containerPort: 3000
72+
readinessProbe:
73+
tcpSocket:
74+
port: 3000
75+
initialDelaySeconds: 5
76+
periodSeconds: 1
77+
volumes:
78+
- name: app-private-key
79+
secret:
80+
secretName: argocd-bot-secret
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: argocd-bot
6+
name: argocd-bot
7+
spec:
8+
ports:
9+
- port: 80
10+
targetPort: 3000
11+
selector:
12+
app.kubernetes.io/name: argocd-bot

deployment/base/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- argocd-bot-deployment.yaml
6+
- argocd-bot-service.yaml

deployment/docker-entrypoint.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

deployment/install.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: argocd-bot
6+
name: argocd-bot
7+
spec:
8+
ports:
9+
- port: 80
10+
targetPort: 3000
11+
selector:
12+
app.kubernetes.io/name: argocd-bot
13+
---
14+
apiVersion: apps/v1
15+
kind: Deployment
16+
metadata:
17+
labels:
18+
app.kubernetes.io/name: argocd-bot
19+
name: argocd-bot
20+
spec:
21+
selector:
22+
matchLabels:
23+
app.kubernetes.io/name: argocd-bot
24+
template:
25+
metadata:
26+
labels:
27+
app.kubernetes.io/name: argocd-bot
28+
spec:
29+
containers:
30+
- command:
31+
- npm
32+
- start
33+
env:
34+
- name: NODE_TLS_REJECT_UNAUTHORIZED
35+
value: "0"
36+
- name: PRIVATE_KEY_PATH
37+
value: /data/key.pem
38+
- name: ARGO_CD_SERVER_IP
39+
valueFrom:
40+
secretKeyRef:
41+
key: ARGOCD_SERVER
42+
name: argocd-bot-secret
43+
- name: ARGOCD_SERVER
44+
valueFrom:
45+
secretKeyRef:
46+
key: ARGOCD_SERVER
47+
name: argocd-bot-secret
48+
- name: ARGO_CD_API_TOKEN
49+
valueFrom:
50+
secretKeyRef:
51+
key: TOKEN
52+
name: argocd-bot-secret
53+
- name: ARGOCD_AUTH_TOKEN
54+
valueFrom:
55+
secretKeyRef:
56+
key: TOKEN
57+
name: argocd-bot-secret
58+
- name: APP_ID
59+
valueFrom:
60+
secretKeyRef:
61+
key: APP_ID
62+
name: argocd-bot-secret
63+
- name: GITHUB_TOKEN
64+
valueFrom:
65+
secretKeyRef:
66+
key: GITHUB_TOKEN
67+
name: argocd-bot-secret
68+
- name: GITHUB_REPO
69+
valueFrom:
70+
secretKeyRef:
71+
key: GITHUB_REPO
72+
name: argocd-bot-secret
73+
- name: WEBHOOK_SECRET
74+
valueFrom:
75+
secretKeyRef:
76+
key: WEBHOOK_SECRET
77+
name: argocd-bot-secret
78+
image: argocd-bot:latest
79+
imagePullPolicy: Always
80+
name: argocd-bot
81+
ports:
82+
- containerPort: 3000
83+
readinessProbe:
84+
initialDelaySeconds: 5
85+
periodSeconds: 1
86+
tcpSocket:
87+
port: 3000
88+
volumeMounts:
89+
- mountPath: /data
90+
name: app-private-key
91+
readOnly: true
92+
volumes:
93+
- name: app-private-key
94+
secret:
95+
secretName: argocd-bot-secret

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"start": "probot run ./lib/index.js",
1414
"test": "jest ./test/",
1515
"build": "tsc"
16+
"manifests": "kustomize build ./deployment/base > deployment/install.yaml",
1617
},
1718
"dependencies": {
1819
"@types/jest": "^24.0.11",

src/argo-bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ ${syncRes.stdout}
353353
return await this.respondWithError("No Kubernetes deployments found, try running \`argo diff --all\`")
354354
}
355355

356-
const jsonItems = jsonArgoCDApps["items"]
356+
const jsonItems = jsonArgoCDApps["items"].filter((item) => item["spec"]["source"]["repoURL"].indexOf(this.argoConfig.getGithubRepo()) > -1);
357357
let foundDiffs = false
358358
// for each app in the ArgoCD Server, attempt to diff with current directory in repo
359359
for (var key in jsonItems) {

0 commit comments

Comments
 (0)