Skip to content

Commit 3617b91

Browse files
committed
restrict access to the hosts configmap
Signed-off-by: Evgeny Slutsky <[email protected]>
1 parent cb71093 commit 3617b91

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
kind: Role
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: hosts-configmap-reader
5+
namespace: openshift-dns
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- configmaps
11+
resourceNames:
12+
- hosts-file
13+
verbs:
14+
- get
15+
- list
16+
- watch
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: RoleBinding
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: hosts-configmap-reader
5+
namespace: openshift-dns
6+
subjects:
7+
- kind: ServiceAccount
8+
name: dns
9+
namespace: openshift-dns
10+
roleRef:
11+
kind: Role
12+
name: hosts-configmap-reader
13+
apiGroup: rbac.authorization.k8s.io

pkg/controllers/hostswatcher.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ func (s *HostsWatcherManager) createOrUpdateConfigMap(ctx context.Context, clien
200200
"app.kubernetes.io/name": "microshift-hosts-watcher",
201201
"app.kubernetes.io/component": "hosts-file-sync",
202202
"app.kubernetes.io/managed-by": "microshift",
203+
// Restrict access to only CoreDNS pods
204+
"microshift.io/access-restricted": "coredns-only",
203205
},
204206
Annotations: map[string]string{
205207
"microshift.io/hosts-file-path": s.file,

0 commit comments

Comments
 (0)