Skip to content

Commit 17dd954

Browse files
Add deployment scripts for the chatbot
Store the secrets, decribe the configuration, and ensure the slack bot has access to exec into pods in the installer namespaces.
1 parent 013190d commit 17dd954

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ prow-artifacts:
158158
oc apply -n ci -f ci-operator/infra/src-cache-origin.yaml
159159
.PHONY: prow-artifacts
160160

161+
prow-ci-chat-bot:
162+
$(MAKE) apply WHAT=ci-operator/infra/openshift/ci-chat-bot/deploy.yaml
163+
161164
prow-release-controller:
162165
oc create imagestream origin-release -o yaml --dry-run | oc apply -f - -n openshift
163166
oc create imagestream origin-v4.0 -o yaml --dry-run | oc apply -f - -n openshift

ci-operator/SECRETS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ For each master, the `jenkins-credentials-${master_url}` secret holds the
122122
password for the Jenkins user in the `password` key. For the `ci.dev` master,
123123
a client cert, key and CA cert are also present for client authentication.
124124

125+
126+
### Slack Bot Credentials
127+
128+
The following Slack bots have their Slack API tokens for the CoreOS Slack organization
129+
stored on the cluster
130+
131+
- cluster-bot as `ci-chat-bot-slack-token`
132+
133+
This token is granted access to talk to the Slack API for automation purposes.
134+
135+
125136
## Secret Regeneration
126137

127138
In order to regenerate the secrets in the case of an emergency, a CI admin can
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ci-chat-bot
2+
===========
3+
4+
Source code for the controller is at https://github.com/openshift/ci-chat-bot
5+
6+
The chat bot uses the CI system to launch clusters via ProwJobs, reusing the same infrastructure
7+
as our CI environments to make reproducing current flakes as painless as possible. It leverages
8+
the jobs defined in `ci-operator/jobs/openshift/release/openshift-release-periodics.yaml` to
9+
launch those clusters, and relies on Prow to tear down the cluster afterwards.
10+
11+
The bot token is managed as a secret in bitwarden and it uses similar permissions to the release
12+
controller to launch new ProwJobs and extract content from their clusters.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
kind: List
2+
apiVersion: v1
3+
items:
4+
- kind: Role
5+
apiVersion: authorization.openshift.io/v1
6+
metadata:
7+
name: ci-chat-bot-prowjob
8+
namespace: ci
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- pods
14+
verbs:
15+
- get
16+
- apiGroups:
17+
- prow.k8s.io
18+
resources:
19+
- prowjobs
20+
verbs:
21+
- get
22+
- list
23+
- watch
24+
- create
25+
- delete
26+
- update
27+
- patch
28+
29+
- kind: RoleBinding
30+
apiVersion: rbac.authorization.k8s.io/v1
31+
metadata:
32+
name: ci-chat-bot-binding-prowjob
33+
namespace: ci
34+
roleRef:
35+
kind: Role
36+
name: ci-chat-bot-prowjob
37+
subjects:
38+
- kind: ServiceAccount
39+
namespace: ci
40+
name: ci-chat-bot
41+
42+
# deploy the bot
43+
- kind: ServiceAccount
44+
apiVersion: v1
45+
metadata:
46+
name: ci-chat-bot
47+
namespace: ci
48+
- kind: Deployment
49+
apiVersion: apps/v1
50+
metadata:
51+
name: ci-chat-bot
52+
namespace: ci
53+
annotations:
54+
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"ci-chat-bot:latest"},"fieldPath":"spec.template.spec.containers[?(@.name==\"bot\")].image"}]'
55+
spec:
56+
selector:
57+
matchLabels:
58+
app: ci-chat-bot
59+
template:
60+
metadata:
61+
labels:
62+
app: ci-chat-bot
63+
spec:
64+
serviceAccountName: ci-chat-bot
65+
volumes:
66+
- name: prow-config
67+
configMap:
68+
name: config
69+
- name: job-config
70+
configMap:
71+
name: job-config
72+
items:
73+
- key: openshift-release-periodics.yaml
74+
path: openshift-release-periodics.yaml
75+
containers:
76+
- name: bot
77+
image: ci-chat-bot:latest
78+
volumeMounts:
79+
- name: prow-config
80+
mountPath: /etc/prow/
81+
- name: job-config
82+
mountPath: /etc/jobs/
83+
env:
84+
- name: BOT_TOKEN
85+
valueFrom:
86+
secretKeyRef:
87+
name: ci-chat-bot-slack-token
88+
key: token
89+
command:
90+
- /usr/bin/ci-chat-bot
91+
- --prow-config=/etc/prow/config.yaml
92+
- --job-config=/etc/jobs/openshift-release-periodics.yaml

ci-operator/populate-secrets-from-bitwarden.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ for login in "openshift-bot" "openshift-build-robot" "openshift-cherrypick-robot
102102
oc label secret "github-credentials-${login}" "ci.openshift.io/managed=true"
103103
done
104104

105+
# Configuration for Slack ci-chat-bot is stored under "Token"
106+
# and the key value is "token" in the secret
107+
oc create secret generic ci-chat-bot-slack-token "$( format_field_value ci-chat-bot-slack-token "Token" "token" )"
108+
oc label secret "ci-chat-bot-slack-token" "ci.openshift.io/managed=true"
109+
105110
# Configuration for GitHub OAuth Apps are stored
106111
# as an opaque field "Client Configuration"
107112
oc create secret generic github-app-credentials "$( format_field_value deck-ci.svc.ci.openshift.org "Client Configuration" "config.json" )"

ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ objects:
3535
subjects:
3636
- kind: SystemGroup
3737
name: system:unauthenticated
38+
# Give edit access to a known bot
39+
- kind: RoleBinding
40+
apiVersion: authorization.openshift.io/v1
41+
metadata:
42+
name: ${JOB_NAME_SAFE}-namespace-editors
43+
namespace: ${NAMESPACE}
44+
roleRef:
45+
name: edit
46+
subjects:
47+
- kind: ServiceAccount
48+
namespace: ci
49+
name: ci-chat-bot
3850

3951
# The e2e pod spins up a cluster, runs e2e tests, and then cleans up the cluster.
4052
- kind: Pod

0 commit comments

Comments
 (0)