feat: added install kubectl and helm
This commit is contained in:
@@ -8,3 +8,11 @@ k3s_datastore_endpoint: ""
|
||||
k3s_token: ""
|
||||
k3s_kubeconfig_mode: "600"
|
||||
k3s_version: "v1.28.3+k3s2"
|
||||
|
||||
k3s_kubectl_force_update: false
|
||||
k3s_kubectl_version: "v1.28.3"
|
||||
k3s_kubectl_url: "https://dl.k8s.io/release/{{ k3s_kubectl_version }}/bin/linux/amd64/kubectl"
|
||||
|
||||
k3s_helm_force_update: false
|
||||
k3s_helm_version: "v3.13.1"
|
||||
k3s_helm_url: "https://github.com/helm/helm/releases/download/{{ k3s_helm_version }}/helm-{{ k3s_helm_version }}-linux-amd64.tar.gz"
|
||||
|
||||
@@ -18,3 +18,15 @@
|
||||
enabled: yes
|
||||
name: k3s
|
||||
when: k3s_env.changed or k3s_master.changed
|
||||
|
||||
- name: Ensure the .kube directory exists
|
||||
file:
|
||||
path: /root/.kube
|
||||
state: directory
|
||||
mode: '0700'
|
||||
|
||||
- name: Link /etc/rancher/k3s/k3s.yaml to /root/.kube/config
|
||||
file:
|
||||
src: /etc/rancher/k3s/k3s.yaml
|
||||
dest: /root/.kube/config
|
||||
state: link
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
dest: "{{ k3s_binary_dir }}/{{ k3s_binary_name }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: 0750
|
||||
when: ansible_facts.architecture == "x86_64"
|
||||
|
||||
- name: Download k3s binary arm64
|
||||
@@ -16,7 +16,7 @@
|
||||
dest: "{{ k3s_binary_dir }}/{{ k3s_binary_name }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: 0750
|
||||
when:
|
||||
- ( ansible_facts.architecture is search("arm") and
|
||||
ansible_facts.userspace_bits == "64" ) or
|
||||
@@ -29,7 +29,7 @@
|
||||
dest: "{{ k3s_binary_dir }}/{{ k3s_binary_name }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: 0750
|
||||
when:
|
||||
- ansible_facts.architecture is search("arm")
|
||||
- ansible_facts.userspace_bits == "32"
|
||||
|
||||
15
tasks/installation_helm.yml
Normal file
15
tasks/installation_helm.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Download helm binary
|
||||
get_url:
|
||||
url: "{{ k3s_helm_url }}"
|
||||
dest: "/tmp/helm-{{ k3s_helm_version }}.tar.gz"
|
||||
when: ansible_facts.architecture == "x86_64"
|
||||
|
||||
- name: extract binary
|
||||
unarchive:
|
||||
src: "/tmp/helm-{{ k3s_helm_version }}.tar.gz"
|
||||
dest: "{{ k3s_binary_dir }}/helm"
|
||||
owner: root
|
||||
group: "root"
|
||||
mode: 0750
|
||||
remote_src: true
|
||||
9
tasks/installation_kubectl.yml
Normal file
9
tasks/installation_kubectl.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Download kubectl binary
|
||||
get_url:
|
||||
url: "{{ k3s_kubectl_url }}"
|
||||
dest: "{{ k3s_binary_dir }}/kubectl"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0750
|
||||
when: ansible_facts.architecture == "x86_64"
|
||||
@@ -1,15 +1,33 @@
|
||||
---
|
||||
- name: check if binary already exists
|
||||
- name: check if binary k3s already exists
|
||||
stat:
|
||||
path: "{{ k3s_binary_dir }}/{{ k3s_binary_name }}"
|
||||
register: binary_check_result
|
||||
register: binary_k3s_check_result
|
||||
|
||||
- name: install binary
|
||||
include_tasks: installation.yml
|
||||
when: not binary_check_result.stat.exists or k3s_force_update
|
||||
when: not binary_k3s_check_result.stat.exists or k3s_force_update
|
||||
|
||||
- name: general preparation
|
||||
include_tasks: preparation.yml
|
||||
|
||||
- name: check if binary kubectl already exists
|
||||
stat:
|
||||
path: "{{ k3s_binary_dir }}/kubectl"
|
||||
register: binary_kubectl_check_result
|
||||
|
||||
- name: install binary kubectl
|
||||
include_tasks: installation_kubectl.yml
|
||||
when: not binary_kubectl_check_result.stat.exists or k3s_kubectl_force_update
|
||||
|
||||
- name: check if binary helm already exists
|
||||
stat:
|
||||
path: "{{ k3s_binary_dir }}/helm"
|
||||
register: binary_helm_check_result
|
||||
|
||||
- name: install binary helm
|
||||
include_tasks: installation_helm.yml
|
||||
when: not binary_helm_check_result.stat.exists or k3s_helm_force_update
|
||||
|
||||
- name: configuration
|
||||
include_tasks: configuration.yml
|
||||
|
||||
Reference in New Issue
Block a user