Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-hermann-sva committed Oct 28, 2024
1 parent d7f2dc8 commit 126a8e4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
5 changes: 2 additions & 3 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ install_kubectl: true
install_helm: true
install_rke_installer: true

install_cilium: false
install_cilium: true
cilium_version: 0.16.19
kubectl_version: v1.31.1
helm_version: 3.16.2
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

path_to_kubeconfig: "{{ k3s_kubeconfig_path if install_k3s|bool else rke2_kubeconfig_path }}"
kubeconfig_path: "{{ k3s_kubeconfig_path if install_k3s|bool else rke2_kubeconfig_path }}"
k3s_config:
flannel_backend: none
disable_kube_proxy: true
Expand Down Expand Up @@ -202,7 +202,6 @@ containerd_service_url: https://raw.githubusercontent.com/containerd/containerd/
containerd_service_dest: /usr/lib/systemd/system/
containerd_service_name: containerd.service
containerd_config_folder: /etc/containerd
containerd_importer_script: containerd-importer.sh
containerd_config_file: config.toml
runc_install_url: "https://github.com/opencontainers/runc/releases/download/v{{ runc_version }}/runc.amd64"
runc_bin_dest: /usr/local/sbin/
Expand Down
31 changes: 28 additions & 3 deletions molecule/k3s/k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

vars:
install_k3s: true
k3s_state: present #absent
k3s_state: present #absent #present #absent
k3s_k8s_version: 1.31.1
k3s_release_kind: k3s1
cluster_setup: singlenode
install_cillium: true
deploy_helm_charts: true
fetched_kubeconfig_path: kubeconfig

helm_repositories:
ingress-nginx:
url: https://kubernetes.github.io/ingress-nginx
Expand All @@ -30,7 +32,7 @@
hostNetwork: true
service:
type: ClusterIP
cert-manager:
ref: cert-manager/cert-manager
version: v1.16.1
Expand All @@ -41,7 +43,7 @@
crds:
enabled: true
additional_helm_manifests:
manifests:
cluster_issuer:
manifest: |
apiVersion: cert-manager.io/v1
Expand All @@ -52,5 +54,28 @@
ca:
secretName: root-ca
lb_pool:
manifest: |
apiVersion: cilium.io/v2alpha1
kind: CiliumLoadBalancerIPPool
metadata:
name: first-pool
spec:
blocks:
- start: 10.31.103.11
stop: 10.31.103.12
announcement_policy:
manifest: |
---
apiVersion: cilium.io/v2alpha1
kind: CiliumL2AnnouncementPolicy
metadata:
name: default-l2-announcement-policy
namespace: kube-system
spec:
externalIPs: true
loadBalancerIPs: true
roles:
- role: deploy-configure-rke
2 changes: 1 addition & 1 deletion molecule/k3s/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ platforms:
provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 3
ANSIBLE_VERBOSITY: 1
playbooks:
converge: ${MOLECULE_PLAYBOOK:-k3s.yaml} #converge.yml
inventory:
Expand Down
8 changes: 4 additions & 4 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: "{{ path_to_kubeconfig }}"
kubeconfig: "{{ kubeconfig_path }}"
name: "{{ item.key }}"
chart_ref: "{{ item.value.ref }}"
chart_version: "{{ item.value.version | default('latest') }}"
Expand All @@ -30,8 +30,8 @@

- name: Deploy additional manifests
kubernetes.core.k8s:
kubeconfig: "{{ path_to_kubeconfig }}"
kubeconfig: "{{ kubeconfig_path }}"
state: present
definition: "{{ lookup('template', 'manifest-file.yaml.j2') | from_yaml }}"
loop: "{{ q('ansible.builtin.dict', additional_helm_manifests) }}"
when: inventory_hostname in groups['initial_master_node'] and additional_helm_manifests is defined
loop: "{{ q('ansible.builtin.dict', manifests) }}"
when: inventory_hostname in groups['initial_master_node'] and manifests is defined
9 changes: 5 additions & 4 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
url: "{{ rke2_airgapped_image_url }}"
dest: "{{ rke2_airgapped_install_dir }}/{{ rke2_airgapped_archive }}"
validate_certs: "{{ validate_certs }}"

when: rke2_airgapped_installation|bool and not install_k3s

- name: Deploy rke{{ rke_version }}
Expand All @@ -45,7 +45,7 @@

- name: Fetch kubeconfig local to ansible host
ansible.builtin.fetch:
src: "{{ path_to_kubeconfig }}"
src: "{{ kubeconfig_path }}"
dest: "{{ fetched_kubeconfig_path }}"
flat: yes
run_once: true
Expand All @@ -61,6 +61,7 @@

- name: Deploy helm charts
ansible.builtin.include_tasks: deploy-helm-charts.yaml
when:
when:
- deploy_helm_charts | bool
- (k3s_state == "present" or rke2_state == "present")
- k3s_state != "absent"
- rke_state != "absent"

0 comments on commit 126a8e4

Please sign in to comment.