-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo-cosign.yaml
175 lines (175 loc) · 4.71 KB
/
demo-cosign.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# install cosign cli from release page: https://github.com/sigstore/cosign/releases
# install kubectl cli, e.g. for linux curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
# get cluster credentials to connect to Kubernetes cluster
# get MTR credentials to sign remote image
#
# kubectl create namespace demoapp
# cosign login mtr.devops.telekom.de -u xxxx -p xxxxx
# cosign generate-key-pair k8s://demoapp/cosigndemo
# cosign sign --key k8s://demoapp/cosigndemo mtr.devops.telekom.de/cosigndemo/nginx-non-root:latest
# or create key offline and only store public key
# cosign generate-key-pair
# cosign sign --key cosign.key mtr.devops.telekom.de/cosigndemo/nginx-non-root:latest
# kubectl -n demoapp create secret generic cosigndemp --from-file=cosign.pub=cosign.pub
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demoapp-deployment
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: demoapp
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: demoapp
spec:
containers:
- image: mtr.devops.telekom.de/cosigndemo/nginx-non-root:latest
imagePullPolicy: Always
name: demoapp
ports:
- containerPort: 8080
name: 8080tcp
protocol: TCP
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
capabilities: {}
privileged: false
runAsNonRoot: true
stdin: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/share/nginx/html
name: demoapp-config
imagePullSecrets:
- name: cosigndemo-pull
dnsPolicy: ClusterFirst
initContainers:
- args:
- verify
- --key
- k8s://demoapp/cosigndemo
- mtr.devops.telekom.de/cosigndemo/nginx-non-root:latest
command:
- cosign
image: mtr.devops.telekom.de/cosigndemo/cosign:v1.8.0
imagePullPolicy: Always
name: sigcheck
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
securityContext:
runAsNonRoot: true
runAsUser: 65532
volumeMounts:
- name: cosigndemo-pull
readOnly: true
mountPath: /home/nonroot/.docker/
stdin: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
tty: true
nodeSelector:
role: worker
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccountName: demoapp
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: demoapp-config
name: demoapp-config
- name: cosigndemo-pull
secret:
secretName: cosigndemo-pull
items:
- key: .dockerconfigjson
path: config.json
---
apiVersion: v1
kind: ConfigMap
metadata:
name: demoapp-config
data:
index.html: |
<html>
<body>
<h1>Greetings from MCSPS</h1>
</body>
</html>
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: demoapp
name: demoapp
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
labels:
app: demoapp
name: demoapp
rules:
- apiGroups:
- ""
resources:
- "secrets"
verbs:
- "get"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app: demoapp
name: demoapp
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: demoapp
subjects:
- kind: ServiceAccount
name: demoapp
---
apiVersion: v1
data:
cosign.pub: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFS1BhWUhnZEVEQ3ltcGx5emlIdkJ5UjNxRkhZdgppaWxlMCtFMEtzVzFqWkhJa1p4UWN3aGsySjNqSm5VdTdmcjcrd05DeENkVEdYQmhBSTJveE1LbWx3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
kind: Secret
metadata:
name: cosigndemo
type: Opaque
---
apiVersion: v1
data:
.dockerconfigjson: ewogICJhdXRocyI6IHsKICAgICJtdHIuZGV2b3BzLnRlbGVrb20uZGUiOiB7CiAgICAgICJhdXRoIjogIlkyOXphV2R1WkdWdGJ5dHdkV3hzT2psRFFrVmFWMGxYTUUxT05GVkhRa3hRV0ZKTFVGVkVORXRVUWtjNFZ6QkpUbG8xVFRCQldUWlhRMDlEU1RCR01qTlNOekpWVURoWVZWaFRURVZEUzBJPSIsCiAgICAgICJlbWFpbCI6ICIiCiAgICB9CiAgfQp9
kind: Secret
metadata:
name: cosigndemo-pull
type: kubernetes.io/dockerconfigjson