Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
kube-proxy shouldn't reuse kubelet's credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
ericchiang committed Nov 7, 2017
1 parent f617c9d commit d0106e4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
AssetPathManifests = "manifests"
AssetPathKubelet = "manifests/kubelet.yaml"
AssetPathProxy = "manifests/kube-proxy.yaml"
AssetPathProxyKubeConfig = "manifests/kube-proxy-kubeconfig.yaml"
AssetPathKubeFlannel = "manifests/kube-flannel.yaml"
AssetPathKubeFlannelCfg = "manifests/kube-flannel-cfg.yaml"
AssetPathCalico = "manifests/calico.yaml"
Expand Down
34 changes: 30 additions & 4 deletions pkg/asset/internal/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ spec:
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
- name: etc-kubernetes
- name: kubeconfig
mountPath: /etc/kubernetes
readOnly: true
hostNetwork: true
Expand All @@ -786,15 +786,41 @@ spec:
- hostPath:
path: /usr/share/ca-certificates
name: ssl-certs-host
- name: etc-kubernetes
hostPath:
path: /etc/kubernetes
- name: kubeconfig
secret:
secretName: kube-proxy-kubeconfig
updateStrategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
`)

var ProxyKubeConfigTemplate = []byte(`apiVersion: v1
kind: Secret
metadata:
name: kube-proxy-kubeconfig
namespace: kube-system
stringData:
kubeconfig: |
apiVersion: v1
clusters:
- name: local
cluster:
# Must use actual external API server address. Internal IP is setup by
# kube-proxy itself.
server: {{ .Server }}
certificate-authority-data: {{ .CACert }}
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:
Expand Down
6 changes: 5 additions & 1 deletion pkg/asset/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ func newKubeletKubeConfigAssets(assets Assets, conf Config) ([]Asset, error) {
if err != nil {
return nil, err
}
return []Asset{assetTokenFile, assetKubeConfig}, nil
assetProxyKubeConfig, err := assetFromTemplate(AssetPathProxyKubeConfig, internal.ProxyKubeConfigTemplate, cfg)
if err != nil {
return nil, err
}
return []Asset{assetTokenFile, assetKubeConfig, assetProxyKubeConfig}, nil
}

func newSelfHostedEtcdSecretAssets(assets Assets) (Assets, error) {
Expand Down

0 comments on commit d0106e4

Please sign in to comment.