This repository has been archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
pkg/asset: use service accounts for checkpointer and kube-proxy creds #767
Merged
dghubble
merged 1 commit into
kubernetes-retired:master
from
ericchiang:authn-checkpointer-kube-proxy-sa
Nov 15, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,7 @@ spec: | |
command: | ||
- /checkpoint | ||
- --lock-file=/var/run/lock/pod-checkpointer.lock | ||
- --kubeconfig=/etc/checkpointer/kubeconfig | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
|
@@ -405,10 +406,13 @@ spec: | |
fieldPath: metadata.namespace | ||
imagePullPolicy: Always | ||
volumeMounts: | ||
- mountPath: /etc/checkpointer | ||
name: kubeconfig | ||
- mountPath: /etc/kubernetes | ||
name: etc-kubernetes | ||
- mountPath: /var/run | ||
name: var-run | ||
serviceAccountName: pod-checkpointer | ||
hostNetwork: true | ||
nodeSelector: | ||
node-role.kubernetes.io/master: "" | ||
|
@@ -418,6 +422,9 @@ spec: | |
operator: Exists | ||
effect: NoSchedule | ||
volumes: | ||
- name: kubeconfig | ||
secret: | ||
secretName: kubeconfig-in-cluster | ||
- name: etc-kubernetes | ||
hostPath: | ||
path: /etc/kubernetes | ||
|
@@ -430,6 +437,43 @@ spec: | |
type: RollingUpdate | ||
`) | ||
|
||
var CheckpointerServiceAccount = []byte(`apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
namespace: kube-system | ||
name: pod-checkpointer | ||
`) | ||
|
||
// TODO: Drop checkpointer RBAC resources to a Role and RoleBinding if | ||
// the checkpoint switches to only watching kube-system. | ||
|
||
var CheckpointerRole = []byte(`apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: pod-checkpointer | ||
rules: | ||
- apiGroups: [""] # "" indicates the core API group | ||
resources: ["pods"] | ||
verbs: ["get", "watch", "list"] | ||
- apiGroups: [""] # "" indicates the core API group | ||
resources: ["secrets", "configmaps"] | ||
verbs: ["get"] | ||
`) | ||
|
||
var CheckpointerRoleBinding = []byte(`apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: pod-checkpointer | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: pod-checkpointer | ||
subjects: | ||
- kind: ServiceAccount | ||
name: pod-checkpointer | ||
namespace: kube-system | ||
`) | ||
|
||
var ControllerManagerTemplate = []byte(`apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
|
@@ -712,10 +756,11 @@ spec: | |
- mountPath: /etc/ssl/certs | ||
name: ssl-certs-host | ||
readOnly: true | ||
- name: etc-kubernetes | ||
- name: kubeconfig | ||
mountPath: /etc/kubernetes | ||
readOnly: true | ||
hostNetwork: true | ||
serviceAccountName: kube-proxy | ||
tolerations: | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
|
@@ -729,15 +774,68 @@ spec: | |
- name: ssl-certs-host | ||
hostPath: | ||
path: /usr/share/ca-certificates | ||
- name: etc-kubernetes | ||
hostPath: | ||
path: /etc/kubernetes | ||
- name: kubeconfig | ||
secret: | ||
secretName: kubeconfig-in-cluster | ||
updateStrategy: | ||
rollingUpdate: | ||
maxUnavailable: 1 | ||
type: RollingUpdate | ||
`) | ||
|
||
var ProxyServiceAccount = []byte(`apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
namespace: kube-system | ||
name: kube-proxy | ||
`) | ||
|
||
var ProxyClusterRoleBinding = []byte(`apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kube-proxy | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: system:node-proxier # Automatically created system role. | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kube-proxy | ||
namespace: kube-system | ||
`) | ||
|
||
// KubeConfigInCluster instructs clients to use their service account token, | ||
// but unlike an in-cluster client doesn't rely on the `KUBERNETES_SERVICE_PORT` | ||
// and `KUBERNETES_PORT` to determine the API servers address. | ||
// | ||
// This kubeconfig is used by bootstrapping pods that might not have access to | ||
// these env vars, such as kube-proxy, which sets up the API server endpoint | ||
// (chicken and egg), and the checkpointer, which needs to run as a static pod | ||
// even if the API server isn't available. | ||
var KubeConfigInClusterTemplate = []byte(`apiVersion: v1 | ||
kind: Secret | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need to be a secret? There is no sensitive data in this resource, would you consider merging PR which changes it to ConfigMap? |
||
metadata: | ||
name: kubeconfig-in-cluster | ||
namespace: kube-system | ||
stringData: | ||
kubeconfig: | | ||
apiVersion: v1 | ||
clusters: | ||
- name: local | ||
cluster: | ||
server: {{ .Server }} | ||
certificate-authority-data: {{ .CACert }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another options is to use |
||
users: | ||
- name: service-account | ||
user: | ||
# Use service account token | ||
tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
contexts: | ||
- context: | ||
cluster: local | ||
user: service-account | ||
`) | ||
|
||
var DNSDeploymentTemplate = []byte(`apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just make this change? It only needs to watch kube-system (also can be follow-up PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can open a separate PR. We'd have to wait the checkpointer change to merged before we drop this to a role, so we can't do it in one PR anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would the checkpointer have to be changed? It just wouldn't have access to non-kube-system right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkpointer attempts to watch all namespaces. If we restrict it now that request will fail. We have to submit a change to the checkpointer.
https://github.com/kubernetes-incubator/bootkube/blob/v0.8.2/pkg/checkpoint/apiserver.go#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened the checkpointer PR #774