Skip to content

Commit 83a0b5b

Browse files
committed
Added alternative release-manifest with kube-rbac-proxy and supporting components for exposing the metrics port. Added make target to build this alternate release-manifest.
1 parent 13ed8d7 commit 83a0b5b

File tree

7 files changed

+95
-1
lines changed

7 files changed

+95
-1
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@ config/.flag.mk: bin/controller-gen $(MANIFEST_GEN_INPUTS)
6363
.PHONY: release-manifests
6464
RELEASE_MANIFEST_TARGETS=$(RELEASE_DIR)/infrastructure-components.yaml $(RELEASE_DIR)/metadata.yaml
6565
RELEASE_MANIFEST_INPUTS=bin/kustomize config/.flag.mk $(shell find config)
66+
RELEASE_MANIFEST_SOURCE_BASE ?= config/default
6667
release-manifests: $(RELEASE_MANIFEST_TARGETS) ## Create kustomized release manifest in $RELEASE_DIR (defaults to out).
6768
$(RELEASE_DIR)/%: $(RELEASE_MANIFEST_INPUTS)
6869
@mkdir -p $(RELEASE_DIR)
6970
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
70-
kustomize build config/default > $(RELEASE_DIR)/infrastructure-components.yaml
71+
kustomize build $(RELEASE_MANIFEST_SOURCE_BASE) > $(RELEASE_DIR)/infrastructure-components.yaml
72+
73+
.PHONY: release-manifests-metrics-port
74+
RELEASE_MANIFEST_SOURCE_BASE = config/default-with-metrics-port
75+
release-manifests-metrics-port: release-manifests
7176

7277
DEEPCOPY_GEN_TARGETS=$(shell find api -type d -name "v*" -exec echo {}\/zz_generated.deepcopy.go \;)
7378
DEEPCOPY_GEN_INPUTS=$(shell find ./api -name "*test*" -prune -o -name "*zz_generated*" -prune -o -type f -print)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: metrics-reader
5+
rules:
6+
- nonResourceURLs:
7+
- "/metrics"
8+
verbs:
9+
- get
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: proxy-role
5+
rules:
6+
- apiGroups:
7+
- authentication.k8s.io
8+
resources:
9+
- tokenreviews
10+
verbs:
11+
- create
12+
- apiGroups:
13+
- authorization.k8s.io
14+
resources:
15+
- subjectaccessreviews
16+
verbs:
17+
- create
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: proxy-rolebinding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: proxy-role
9+
subjects:
10+
- kind: ServiceAccount
11+
name: controller-manager
12+
namespace: system
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
control-plane: controller-manager
6+
name: controller-manager-metrics-service
7+
namespace: system
8+
spec:
9+
ports:
10+
- name: https
11+
port: 8443
12+
protocol: TCP
13+
targetPort: https
14+
selector:
15+
control-plane: capc-controller-manager
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
bases:
5+
- ../default
6+
7+
resources:
8+
- auth_proxy_client_clusterrole.yaml
9+
- auth_proxy_role.yaml
10+
- auth_proxy_role_binding.yaml
11+
- auth_proxy_service.yaml
12+
13+
patchesStrategicMerge:
14+
- manager_auth_proxy_patch.yaml
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This patch inject a sidecar container which is a HTTP proxy for the
2+
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: controller-manager
7+
namespace: system
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: kube-rbac-proxy
13+
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
14+
args:
15+
- "--secure-listen-address=0.0.0.0:8443"
16+
- "--upstream=http://127.0.0.1:8080/"
17+
- "--logtostderr=true"
18+
- "--v=10"
19+
ports:
20+
- containerPort: 8443
21+
protocol: TCP
22+
name: https

0 commit comments

Comments
 (0)