---
apiVersion: kubeadm.k8s.io/v1beta4
kind: JoinConfiguration
discovery:
{% if kubeadm_use_file_discovery %}
  file:
    kubeConfigPath: {{ kube_config_dir }}/cluster-info-discovery-kubeconfig.yaml
{% else %}
  bootstrapToken:
{% if kubeadm_config_api_fqdn is defined %}
    apiServerEndpoint: "{{ kubeadm_config_api_fqdn }}:{{ loadbalancer_apiserver.port | default(kube_apiserver_port) }}"
{% else %}
    apiServerEndpoint: "{{ kubeadm_discovery_address }}"
{% endif %}
    token: {{ kubeadm_token }}
{% if ca_cert_content is defined %}
    caCertHashes:
    - sha256:{{ (ca_cert_content.content | b64decode | community.crypto.x509_certificate_info).public_key_fingerprints.sha256.replace(':', '') }}
{% else %}
    unsafeSkipCAVerification: true
{% endif %}
{% endif %}
  tlsBootstrapToken: {{ kubeadm_token }}
timeouts:
  discovery: {{ discovery_timeout }}
caCertPath: {{ kube_cert_dir }}/ca.crt
{% if kubeadm_cert_controlplane is defined and kubeadm_cert_controlplane %}
controlPlane:
  localAPIEndpoint:
    advertiseAddress: "{{ kube_apiserver_address }}"
    bindPort: {{ kube_apiserver_port }}
  certificateKey: {{ kubeadm_certificate_key }}
{% endif %}
nodeRegistration:
  name: '{{ kube_override_hostname }}'
  criSocket: {{ cri_socket }}
{% if 'calico_rr' in group_names and 'kube_node' not in group_names %}
  taints:
  - effect: NoSchedule
    key: node-role.kubernetes.io/calico-rr
{% endif %}
{% if kubeadm_patches | length > 0 %}
patches:
  directory: {{ kubeadm_patches_dir }}
{% endif %}
