|
| 1 | +/* |
| 2 | +Copyright 2018 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package project |
| 18 | + |
| 19 | +import ( |
| 20 | + "path/filepath" |
| 21 | + |
| 22 | + "sigs.k8s.io/kubebuilder/pkg/scaffold/input" |
| 23 | +) |
| 24 | + |
| 25 | +var _ input.File = &KustomizeAuthProxyPatch{} |
| 26 | + |
| 27 | +// KustomizeAuthProxyPatch scaffolds the patch file for enabling |
| 28 | +// prometheus metrics for manager Pod. |
| 29 | +type KustomizeAuthProxyPatch struct { |
| 30 | + input.Input |
| 31 | +} |
| 32 | + |
| 33 | +// GetInput implements input.File |
| 34 | +func (c *KustomizeAuthProxyPatch) GetInput() (input.Input, error) { |
| 35 | + if c.Path == "" { |
| 36 | + c.Path = filepath.Join("config", "default", "manager_auth_proxy_patch.yaml") |
| 37 | + } |
| 38 | + c.TemplateBody = kustomizeAuthProxyPatchTemplate |
| 39 | + c.Input.IfExistsAction = input.Error |
| 40 | + return c.Input, nil |
| 41 | +} |
| 42 | + |
| 43 | +var kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the controller manager, |
| 44 | +# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. |
| 45 | +apiVersion: apps/v1 |
| 46 | +kind: StatefulSet |
| 47 | +metadata: |
| 48 | + name: controller-manager |
| 49 | + namespace: system |
| 50 | +spec: |
| 51 | + template: |
| 52 | + spec: |
| 53 | + containers: |
| 54 | + - name: kube-rbac-proxy |
| 55 | + image: quay.io/brancz/kube-rbac-proxy:v0.4.0 |
| 56 | + args: |
| 57 | + - "--secure-listen-address=0.0.0.0:8443" |
| 58 | + - "--upstream=http://127.0.0.1:8080/" |
| 59 | + - "--logtostderr=true" |
| 60 | + - "--v=10" |
| 61 | + ports: |
| 62 | + - containerPort: 8443 |
| 63 | + name: https |
| 64 | + - name: manager |
| 65 | + args: |
| 66 | + - "--metrics-addr=127.0.0.1:8080" |
| 67 | +` |
0 commit comments