-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mengqi Yu
committed
Dec 10, 2018
1 parent
001b3ad
commit a227e64
Showing
13 changed files
with
357 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright 2018 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package project | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
var _ input.File = &KustomizeAuthProxyPatch{} | ||
|
||
// KustomizeAuthProxyPatch scaffolds the patch file for enabling | ||
// prometheus metrics for manager Pod. | ||
type KustomizeAuthProxyPatch struct { | ||
input.Input | ||
} | ||
|
||
// GetInput implements input.File | ||
func (c *KustomizeAuthProxyPatch) GetInput() (input.Input, error) { | ||
if c.Path == "" { | ||
c.Path = filepath.Join("config", "default", "manager_auth_proxy_patch.yaml") | ||
} | ||
c.TemplateBody = kustomizeAuthProxyPatchTemplate | ||
c.Input.IfExistsAction = input.Error | ||
return c.Input, nil | ||
} | ||
|
||
var kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the controller manager, | ||
# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: kube-rbac-proxy | ||
image: quay.io/brancz/kube-rbac-proxy:v0.4.0 | ||
args: | ||
- "--secure-listen-address=0.0.0.0:8443" | ||
- "--upstream=http://127.0.0.1:8080/" | ||
- "--logtostderr=true" | ||
- "--v=10" | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
- name: manager | ||
args: | ||
- "--metrics-addr=127.0.0.1:8080" | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2018 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package resource | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
var _ input.File = &AuthProxyRole{} | ||
|
||
// AuthProxyRole scaffolds the config/rbac/auth_proxy_role.yaml file | ||
type AuthProxyRole struct { | ||
input.Input | ||
|
||
// Resource is a resource in the API group | ||
Resource *Resource | ||
} | ||
|
||
// GetInput implements input.File | ||
func (r *AuthProxyRole) GetInput() (input.Input, error) { | ||
if r.Path == "" { | ||
r.Path = filepath.Join("config", "rbac", "auth_proxy_role.yaml") | ||
} | ||
r.TemplateBody = proxyRoleTemplate | ||
return r.Input, nil | ||
} | ||
|
||
var proxyRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: proxy-role | ||
rules: | ||
- apiGroups: ["authentication.k8s.io"] | ||
resources: | ||
- tokenreviews | ||
verbs: ["create"] | ||
- apiGroups: ["authorization.k8s.io"] | ||
resources: | ||
- subjectaccessreviews | ||
verbs: ["create"] | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2018 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package resource | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
var _ input.File = &AuthProxyRoleBinding{} | ||
|
||
// AuthProxyRoleBinding scaffolds the config/rbac/auth_proxy_role_binding_rbac.yaml file | ||
type AuthProxyRoleBinding struct { | ||
input.Input | ||
|
||
// Resource is a resource in the API group | ||
Resource *Resource | ||
} | ||
|
||
// GetInput implements input.File | ||
func (r *AuthProxyRoleBinding) GetInput() (input.Input, error) { | ||
if r.Path == "" { | ||
r.Path = filepath.Join("config", "rbac", "auth_proxy_role_binding.yaml") | ||
} | ||
r.TemplateBody = proxyRoleBindinggTemplate | ||
return r.Input, nil | ||
} | ||
|
||
var proxyRoleBindinggTemplate = `apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: proxy-rolebinding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: proxy-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: default | ||
namespace: system | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2018 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package resource | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
var _ input.File = &AuthProxyService{} | ||
|
||
// AuthProxyService scaffolds the config/rbac/auth_proxy_role.yaml file | ||
type AuthProxyService struct { | ||
input.Input | ||
|
||
// Resource is a resource in the API group | ||
Resource *Resource | ||
} | ||
|
||
// GetInput implements input.File | ||
func (r *AuthProxyService) GetInput() (input.Input, error) { | ||
if r.Path == "" { | ||
r.Path = filepath.Join("config", "rbac", "auth_proxy_service.yaml") | ||
} | ||
r.TemplateBody = AuthProxyServiceTemplate | ||
return r.Input, nil | ||
} | ||
|
||
var AuthProxyServiceTemplate = `apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
prometheus.io/port: "8443" | ||
prometheus.io/scheme: https | ||
prometheus.io/scrape: "true" | ||
labels: | ||
control-plane: controller-manager | ||
controller-tools.k8s.io: "1.0" | ||
name: controller-manager-metrics-service | ||
namespace: system | ||
spec: | ||
ports: | ||
- name: https | ||
port: 8443 | ||
targetPort: https | ||
selector: | ||
control-plane: controller-manager | ||
controller-tools.k8s.io: "1.0" | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This patch inject a sidecar container which is a HTTP proxy for the controller manager, | ||
# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: kube-rbac-proxy | ||
image: quay.io/brancz/kube-rbac-proxy:v0.4.0 | ||
args: | ||
- "--secure-listen-address=0.0.0.0:8443" | ||
- "--upstream=http://127.0.0.1:8080/" | ||
- "--logtostderr=true" | ||
- "--v=10" | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
- name: manager | ||
args: | ||
- "--metrics-addr=127.0.0.1:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: proxy-role | ||
rules: | ||
- apiGroups: ["authentication.k8s.io"] | ||
resources: | ||
- tokenreviews | ||
verbs: ["create"] | ||
- apiGroups: ["authorization.k8s.io"] | ||
resources: | ||
- subjectaccessreviews | ||
verbs: ["create"] |
Oops, something went wrong.