Browse Source

configure kubespray to sign service account tokens with a dedicated and stable key

pull/2554/head
georgejdli 6 years ago
committed by Li, George (gl741q)
parent
commit
c8f857eae4
4 changed files with 15 additions and 2 deletions
  1. 2
      roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2
  2. 2
      roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2
  3. 11
      roles/kubernetes/secrets/files/make-ssl.sh
  4. 2
      roles/kubernetes/secrets/tasks/gen_certs_script.yml

2
roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2

@ -63,7 +63,7 @@ spec:
{% if kube_token_auth|default(true) %}
- --token-auth-file={{ kube_token_dir }}/known_tokens.csv
{% endif %}
- --service-account-key-file={{ kube_cert_dir }}/apiserver-key.pem
- --service-account-key-file={{ kube_cert_dir }}/service-account-key.pem
{% if kube_oidc_auth|default(false) and kube_oidc_url is defined and kube_oidc_client_id is defined %}
- --oidc-issuer-url={{ kube_oidc_url }}
- --oidc-client-id={{ kube_oidc_client_id }}

2
roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2

@ -29,7 +29,7 @@ spec:
- controller-manager
- --kubeconfig={{ kube_config_dir }}/kube-controller-manager-kubeconfig.yaml
- --leader-elect=true
- --service-account-private-key-file={{ kube_cert_dir }}/apiserver-key.pem
- --service-account-private-key-file={{ kube_cert_dir }}/service-account-key.pem
- --root-ca-file={{ kube_cert_dir }}/ca.pem
- --cluster-signing-cert-file={{ kube_cert_dir }}/ca.pem
- --cluster-signing-key-file={{ kube_cert_dir }}/ca-key.pem

11
roles/kubernetes/secrets/files/make-ssl.sh

@ -82,6 +82,17 @@ gen_key_and_cert() {
# Admins
if [ -n "$MASTERS" ]; then
# service-account
# If --service-account-private-key-file was previously configured to use apiserver-key.pem then copy that to the new dedicated service-account signing key location to avoid disruptions
if [ -e "$SSLDIR/apiserver-key.pem" ] && ! [ -e "$SSLDIR/service-account-key.pem" ]; then
cp $SSLDIR/apiserver-key.pem $SSLDIR/service-account-key.pem
fi
# Generate dedicated service account signing key if one doesn't exist
if ! [ -e "$SSLDIR/apiserver-key.pem" ] && ! [ -e "$SSLDIR/service-account-key.pem" ]; then
openssl genrsa -out service-account-key.pem 2048 > /dev/null 2>&1
fi
# kube-apiserver
# Generate only if we don't have existing ca and apiserver certs
if ! [ -e "$SSLDIR/ca-key.pem" ] || ! [ -e "$SSLDIR/apiserver-key.pem" ]; then

2
roles/kubernetes/secrets/tasks/gen_certs_script.yml

@ -75,6 +75,7 @@
'kube-controller-manager-key.pem',
'front-proxy-client.pem',
'front-proxy-client-key.pem',
'service-account-key.pem',
{% for node in groups['kube-master'] %}
'admin-{{ node }}.pem',
'admin-{{ node }}-key.pem',
@ -86,6 +87,7 @@
'apiserver-key.pem',
'front-proxy-client.pem',
'front-proxy-client-key.pem',
'service-account-key.pem',
'kube-scheduler.pem',
'kube-scheduler-key.pem',
'kube-controller-manager.pem',

Loading…
Cancel
Save