Skip to content

Commit c937b96

Browse files
committed
coco: automate pull-secret via ESO cross-namespace
Peer-pods don't have access to the node's pull-secret, needed for private repos. Use ESO kubernetes provider to sync pull-secret from openshift-config to the workload namespace. Signed-off-by: Beraldo Leal <bleal@redhat.com>
1 parent 157d5f7 commit c937b96

4 files changed

Lines changed: 73 additions & 4 deletions

File tree

charts/hello-coco/templates/pod.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ spec:
1414
# not individual containers. All containers in this pod are part of the same trust boundary.
1515
shareProcessNamespace: true
1616
serviceAccountName: spire-agent
17-
# TODO: Make imagePullSecrets configurable like qtodo chart pattern (values.yaml + conditional)
18-
# Currently hardcoded 'global-pull-secret' which must be manually created in the namespace
19-
# Should either: 1) use ServiceAccount.imagePullSecrets, or 2) be conditional from values
2017
imagePullSecrets:
21-
- name: global-pull-secret
18+
- name: pull-secret
2219

2320
containers:
2421
# SPIRE Agent Sidecar
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: external-secrets.io/v1beta1
2+
kind: ExternalSecret
3+
metadata:
4+
name: pull-secret
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
refreshInterval: 1h
8+
secretStoreRef:
9+
name: openshift-config
10+
kind: SecretStore
11+
target:
12+
name: pull-secret
13+
template:
14+
type: kubernetes.io/dockerconfigjson
15+
data:
16+
.dockerconfigjson: "{{ `{{ .dockerconfigjson | toString }}` }}"
17+
data:
18+
- secretKey: dockerconfigjson
19+
remoteRef:
20+
key: pull-secret
21+
property: .dockerconfigjson
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: pull-secret-reader
5+
namespace: {{ .Release.Namespace }}
6+
---
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: ClusterRole
9+
metadata:
10+
name: pull-secret-reader
11+
rules:
12+
- apiGroups: [""]
13+
resources: ["secrets"]
14+
resourceNames: ["pull-secret"]
15+
verbs: ["get", "list", "watch"]
16+
- apiGroups: [""]
17+
resources: ["namespaces"]
18+
verbs: ["get"]
19+
- apiGroups: ["authorization.k8s.io"]
20+
resources: ["selfsubjectrulesreviews"]
21+
verbs: ["create"]
22+
---
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
kind: ClusterRoleBinding
25+
metadata:
26+
name: pull-secret-reader
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: ClusterRole
30+
name: pull-secret-reader
31+
subjects:
32+
- kind: ServiceAccount
33+
name: pull-secret-reader
34+
namespace: {{ .Release.Namespace }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: external-secrets.io/v1beta1
2+
kind: SecretStore
3+
metadata:
4+
name: openshift-config
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
provider:
8+
kubernetes:
9+
remoteNamespace: openshift-config
10+
server:
11+
caProvider:
12+
type: ConfigMap
13+
name: kube-root-ca.crt
14+
key: ca.crt
15+
auth:
16+
serviceAccount:
17+
name: pull-secret-reader

0 commit comments

Comments
 (0)