-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeployment.yaml
159 lines (157 loc) · 4.65 KB
/
deployment.yaml
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
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ${JOB_CONFIG_MAP}
namespace: ${NAMESPACE}
data:
spec: |
template:
spec:
serviceAccountName: ${JOB_SERVICE_ACCOUNT}
#runtimeClassName: gvisor
restartPolicy: OnFailure
nodeSelector:
cloud.google.com/gke-nodepool: batch
tolerations:
- key: sandbox.gke.io/runtime
operator: Equal
value: gvisor
effect: NoSchedule
containers:
- name: cis-scan
image: ${CIS_IMAGE}
imagePullPolicy: Always
env:
- name: BQ_DATASET
value: ${CIS_DATASET}
- name: CIS_CONTROLS_IGNORE
value: ${CIS_CONTROLS_IGNORE}
- name: SLACK_TOKEN
valueFrom:
secretKeyRef:
name: ${JOB_SECRET}
key: SLACK_TOKEN
- name: SLACK_CHANNEL_WEEKLY_REPORT
valueFrom:
secretKeyRef:
name: ${JOB_SECRET}
key: SLACK_CHANNEL_WEEKLY_REPORT
- name: TARGET_PROJECT_ID
valueFrom:
fieldRef:
fieldPath: metadata.annotations['GCP_PROJECT_ID']
- name: FIRESTORE_COLLECTION
valueFrom:
fieldRef:
fieldPath: metadata.annotations['FIRESTORE_COLLECTION']
- name: SLACK_CHANNEL
valueFrom:
fieldRef:
fieldPath: metadata.annotations['SLACK_CHANNEL']
- name: SLACK_RESULTS_URL
valueFrom:
fieldRef:
fieldPath: metadata.annotations['SLACK_RESULTS_URL']
resources:
requests:
memory: 2Gi
---
apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
kind: BigQueryDataset
metadata:
name: ${CIS_DATASET}
namespace: ${NAMESPACE}
annotations:
cnrm.cloud.google.com/deletion-policy: abandon
spec:
description: "CIS scan results"
access:
- role: OWNER
specialGroup: projectOwners
- role: READER
userByEmail: ${CRON_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
- role: WRITER
userByEmail: ${JOB_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
- role: WRITER
userByEmail: ${SDARQ_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
name: ${JOB_SERVICE_ACCOUNT}-sa-bq-policy
namespace: ${NAMESPACE}
spec:
member: serviceAccount:${JOB_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
role: roles/bigquery.jobUser
resourceRef:
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
external: projects/${PROJECT_ID}
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
name: ${JOB_SERVICE_ACCOUNT}-sa-firestore-policy
namespace: ${NAMESPACE}
spec:
member: serviceAccount:${JOB_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
role: roles/datastore.user
resourceRef:
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
external: projects/${PROJECT_ID}
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicy
metadata:
name: ${JOB_TOPIC}-policy
namespace: ${NAMESPACE}
spec:
resourceRef:
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
name: ${JOB_TOPIC}
bindings:
- role: roles/pubsub.publisher
members:
- serviceAccount:${CRON_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
- serviceAccount:${SDARQ_SERVICE_ACCOUNT}@${PROJECT_ID}.iam.gserviceaccount.com
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: cis-trigger-weekly
namespace: ${NAMESPACE}
spec:
schedule: "0 7 * * 4"
jobTemplate:
spec:
template:
spec:
serviceAccountName: ${CRON_SERVICE_ACCOUNT}
runtimeClassName: gvisor
nodeSelector:
cloud.google.com/gke-nodepool: batch
restartPolicy: OnFailure
containers:
- name: cis-scan
image: ${CIS_IMAGE}
command: ['python3', '/scanweekly.py']
env:
- name: DATASET_PROJECT_ID
value: ${PROJECT_ID}
- name: CIS_PROD_PROJECTS
value: ${CIS_PROD_PROJECTS}
- name: JOB_TOPIC
value: ${JOB_TOPIC}
- name: SLACK_CHANNEL_WEEKLY_REPORT
valueFrom:
secretKeyRef:
name: ${JOB_SECRET}
key: SLACK_CHANNEL_WEEKLY_REPORT
- name: SDARQ_HOST
valueFrom:
secretKeyRef:
name: ${JOB_SECRET}
key: SDARQ_HOST