Skip to content

Commit

Permalink
updated config
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-hermann-sva committed Oct 27, 2024
1 parent df76ba7 commit fbfe146
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rke2_server_service: rke2-server.service
rke2_node_register_port: 9345
k8s_api_port: 6443
rke2_uninstall_script: /usr/local/bin/rke2-uninstall.sh
rke2_fetched_kubeconfig_path: ./kubeconfig
fetched_kubeconfig_path: ./kubeconfig
rke2_path_to_generated_token: "{{ rke_dir }}/server/node-token"
rke2_additional_manifests_path: "{{ rke_dir }}/server/manifests"
rke2_release_kind: rke2r1 #rke2r2
Expand Down Expand Up @@ -164,7 +164,7 @@ k3s_config_dir: /etc/rancher/k3s
k3s_config_name: k3s-config.yaml
k3s_kubeconfig_path: /etc/rancher/k3s/k3s.yaml

helm_kubeconfig: "{{ k3s_kubeconfig_path if install_k3s|bool else rke2_kubeconfig_path }}"
path_to_kubeconfig: "{{ k3s_kubeconfig_path if install_k3s|bool else rke2_kubeconfig_path }}"
k3s_config:
flannel_backend: none
disable_kube_proxy: true
Expand Down
4 changes: 2 additions & 2 deletions tasks/deploy-helm-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

- name: Deploy helm charts
kubernetes.core.helm:
kubeconfig: "{{ helm_kubeconfig }}"
kubeconfig: "{{ path_to_kubeconfig }}"
name: "{{ item.key }}"
chart_ref: "{{ item.value.ref }}"
chart_version: "{{ item.value.version | default('latest') }}"
Expand All @@ -30,7 +30,7 @@

- name: Deploy additional manifests
kubernetes.core.k8s:
kubeconfig: "{{ helm_kubeconfig }}"
kubeconfig: "{{ path_to_kubeconfig }}"
state: present
definition: "{{ lookup('template', 'manifest-file.yaml.j2') | from_yaml }}"
loop: "{{ q('ansible.builtin.dict', additional_helm_manifests) }}"
Expand Down
7 changes: 7 additions & 0 deletions tasks/deploy-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
run_once: true
delegate_to: initial_master_node

- name: Add external ip to kubeconfig
ansible.builtin.lineinfile:
path: "{{ k3s_kubeconfig_path }}"
regexp: "127.0.0.1:{{ k8s_api_port }}"
line: " server: https://{% for host in groups['initial_master_node'] %}{{ hostvars[host]['ansible_default_ipv4']['address'] }}{% endfor %}:{{ k8s_api_port }}"
delegate_to: initial_master_node

- name: Deploy additional nodes
ansible.builtin.shell: |
curl -sfL {{ k3s_installscript_url }} | sh -s -
Expand Down
4 changes: 2 additions & 2 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

- name: Fetch kubeconfig local to ansible host
ansible.builtin.fetch:
src: "{{ rke2_kubeconfig_path }}"
dest: "{{ rke2_fetched_kubeconfig_path }}"
src: "{{ path_to_kubeconfig }}"
dest: "{{ fetched_kubeconfig_path }}"
flat: yes
run_once: true
when: inventory_hostname in groups['initial_master_node'] and fetch_kubeconfig|bool
Expand Down

0 comments on commit fbfe146

Please sign in to comment.