Przeglądaj źródła

Create individual serving cert and loopback kubeconfig for additional masters.

Deprecates use of 'create-master-certs' for generating master serving
certificate and loopback kubeconfig in order to reference the first
master's CA serial file.
Andrew Butcher 8 lat temu
rodzic
commit
b30c15b839

+ 3 - 1
filter_plugins/openshift_master.py

@@ -517,7 +517,9 @@ class FilterModule(object):
         ''' Return certificates to synchronize based on facts. '''
         if not issubclass(type(hostvars), dict):
             raise errors.AnsibleFilterError("|failed expects hostvars is a dict")
-        certs = ['admin.crt',
+        certs = ['ca.crt',
+                 'ca.key',
+                 'admin.crt',
                  'admin.key',
                  'admin.kubeconfig',
                  'master.kubelet-client.crt',

+ 0 - 4
playbooks/common/openshift-cluster/redeploy-certificates.yml

@@ -108,10 +108,6 @@
                                      | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
                                      | oo_collect('openshift.common.hostname')
                                      | default(none, true) }}"
-    openshift_master_hostnames: "{{ hostvars
-                                    | oo_select_keys(groups['oo_masters_to_config'] | default([]))
-                                    | oo_collect('openshift.common.all_hostnames')
-                                    | oo_flatten | unique }}"
     openshift_certificates_redeploy: true
   - role: openshift_etcd_client_certificates
     etcd_certificates_redeploy: true

+ 0 - 4
playbooks/common/openshift-master/config.yml

@@ -134,10 +134,6 @@
                                      | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
                                      | oo_collect('openshift.common.hostname')
                                      | default(none, true) }}"
-    openshift_master_hostnames: "{{ hostvars
-                                    | oo_select_keys(groups['oo_masters_to_config'] | default([]))
-                                    | oo_collect('openshift.common.all_hostnames')
-                                    | oo_flatten | unique }}"
     openshift_master_hosts: "{{ groups.oo_masters_to_config }}"
     etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
     etcd_cert_subdir: "openshift-master-{{ openshift.common.hostname }}"

+ 1 - 1
roles/openshift_ca/tasks/main.yml

@@ -86,7 +86,7 @@
     {% for named_ca_certificate in openshift.master.named_certificates | default([]) | oo_collect('cafile') %}
     --certificate-authority {{ named_ca_certificate }}
     {% endfor %}
-    --hostnames={{ openshift_master_hostnames | join(',') }}
+    --hostnames={{ openshift.common.all_hostnames | join(',') }}
     --master={{ openshift.master.api_url }}
     --public-master={{ openshift.master.public_api_url }}
     --cert-dir={{ openshift_ca_config_dir }}

+ 28 - 16
roles/openshift_master_certificates/tasks/main.yml

@@ -39,31 +39,43 @@
   when: master_certs_missing | bool and inventory_hostname != openshift_ca_host
   delegate_to: "{{ openshift_ca_host }}"
 
-- file:
-    src: "{{ openshift_master_config_dir }}/{{ item }}"
-    dest: "{{ openshift_master_generated_config_dir }}/{{ item }}"
-    state: hard
-  with_items:
-  - ca.crt
-  - ca.key
-  - ca.serial.txt
-  when: master_certs_missing | bool and inventory_hostname != openshift_ca_host
-  delegate_to: "{{ openshift_ca_host }}"
-
-- name: Create the master certificates if they do not already exist
+- name: Create the master server certificate
   command: >
-    {{ openshift.common.client_binary }} adm create-master-certs
+    {{ openshift.common.client_binary }} adm ca create-server-cert
     {% for named_ca_certificate in openshift.master.named_certificates | default([]) | oo_collect('cafile') %}
     --certificate-authority {{ named_ca_certificate }}
     {% endfor %}
     --hostnames={{ openshift.common.all_hostnames | join(',') }}
-    --master={{ openshift.master.api_url }}
-    --public-master={{ openshift.master.public_api_url }}
-    --cert-dir={{ openshift_master_generated_config_dir }}
+    --cert={{ openshift_master_generated_config_dir }}/master.server.crt
+    --key={{ openshift_master_generated_config_dir }}/master.server.key
+    --signer-cert={{ openshift_ca_cert }}
+    --signer-key={{ openshift_ca_key }}
+    --signer-serial={{ openshift_ca_serial }}
     --overwrite=false
   when: master_certs_missing | bool and inventory_hostname != openshift_ca_host
   delegate_to: "{{ openshift_ca_host }}"
 
+- name: Generate the master client config
+  command: >
+    {{ openshift.common.client_binary }} adm create-api-client-config
+      {% for named_ca_certificate in openshift.master.named_certificates | default([]) | oo_collect('cafile') %}
+      --certificate-authority {{ named_ca_certificate }}
+      {% endfor %}
+      --certificate-authority={{ openshift_ca_cert }}
+      --client-dir={{ openshift_master_generated_config_dir }}
+      --groups=system:masters,system:openshift-master
+      --master={{ openshift.master.api_url }}
+      --public-master={{ openshift.master.public_api_url }}
+      --signer-cert={{ openshift_ca_cert }}
+      --signer-key={{ openshift_ca_key }}
+      --signer-serial={{ openshift_ca_serial }}
+      --user=system:openshift-master
+      --basename=openshift-master
+  args:
+    creates: "{{ openshift_master_generated_config_dir }}/openshift-master.kubeconfig"
+  when: master_certs_missing | bool and inventory_hostname != openshift_ca_host
+  delegate_to: "{{ openshift_ca_host }}"
+
 - file:
     src: "{{ openshift_master_config_dir }}/{{ item }}"
     dest: "{{ openshift_master_generated_config_dir }}/{{ item }}"