Skip to content

Commit

Permalink
Merge pull request #494 from gmarcy/refresh
Browse files Browse the repository at this point in the history
refactor: remove unused, rename consistency
  • Loading branch information
ccamacho authored Sep 28, 2021
2 parents 3ccd551 + 029cd3d commit 62465ab
Show file tree
Hide file tree
Showing 52 changed files with 412 additions and 527 deletions.
8 changes: 0 additions & 8 deletions kubeinit/hosts/cdk/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=ubuntu
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=ubuntu
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

[extra_nodes:vars]
Expand All @@ -59,7 +52,6 @@ disk=20G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

#
# Hosts definitions
Expand Down
7 changes: 0 additions & 7 deletions kubeinit/hosts/eks/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=centos
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=centos
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

#
Expand Down
7 changes: 0 additions & 7 deletions kubeinit/hosts/k8s/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=centos
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=centos
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

#
Expand Down
7 changes: 0 additions & 7 deletions kubeinit/hosts/kid/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=debian
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=debian
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

#
Expand Down
8 changes: 0 additions & 8 deletions kubeinit/hosts/okd/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=coreos
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=centos
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

[extra_nodes:vars]
Expand All @@ -59,7 +52,6 @@ disk=20G
ram=16777216
vcpus=8
maxvcpus=16
prefix=24

#
# Hosts definitions
Expand Down
7 changes: 0 additions & 7 deletions kubeinit/hosts/rke/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ disk=25G
ram=25165824
vcpus=8
maxvcpus=16
prefix=24

[compute_nodes:vars]
os=ubuntu
disk=30G
ram=8388608
vcpus=8
maxvcpus=16
prefix=24

[service_nodes:vars]
os=ubuntu
disk=150G
ram=12582912
vcpus=8
maxvcpus=16
prefix=24
services="bind,dnsmasq,haproxy,apache,registry" # nexus

#
Expand Down
1 change: 0 additions & 1 deletion kubeinit/roles/kubeinit_cdk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
vars:
kubeinit_deployment_node_name: "{{ cluster_role_item }}"
kubeinit_deployment_delegate: "{{ hostvars[cluster_role_item].target }}"
kubeinit_deployment_role: cluster
when: kubeinit_cluster_nodes_deployed is not defined or not kubeinit_cluster_nodes_deployed

- name: Add cluster authorized keys in cluster nodes
Expand Down
3 changes: 2 additions & 1 deletion kubeinit/roles/kubeinit_cdk/tasks/post_deployment_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
echo "Finished"
args:
executable: /bin/bash
changed_when: false
register: _result
changed_when: "_result.rc == 0"
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_cdk/tasks/prepare_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
kubeinit_deployment_pod_name: "{{ hostvars[kubeinit_provision_service_node].guest_name }}-pod"
kubeinit_deployment_delegate: "{{ hostvars[kubeinit_provision_service_node].target }}"
kubeinit_deployment_os: "{{ hostvars[kubeinit_provision_service_node].os }}"
kubeinit_deployment_type: container
kubeinit_deployment_role: provision

- name: Add task-prepare-cluster to tasks_completed
ansible.builtin.add_host:
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_eks/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ kubeinit_eks_hide_sensitive_logs: true

kubeinit_eks_pod_network_cidr: 10.244.0.0/16
kubeinit_eks_service_network_cidr: 10.96.0.0/12

kubeinit_eks_kubernetes_version: 1.21.4
1 change: 0 additions & 1 deletion kubeinit/roles/kubeinit_eks/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
vars:
kubeinit_deployment_node_name: "{{ cluster_role_item }}"
kubeinit_deployment_delegate: "{{ hostvars[cluster_role_item].target }}"
kubeinit_deployment_role: cluster
when: kubeinit_cluster_nodes_deployed is not defined or not kubeinit_cluster_nodes_deployed

- name: Add cluster authorized keys in cluster nodes
Expand Down
19 changes: 10 additions & 9 deletions kubeinit/roles/kubeinit_eks/tasks/post_deployment_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- name: Fetch the kubeconfig from the first controller node
ansible.builtin.slurp:
src: ~/.kube/config
register: kubeinit_eks_cluster_kubeconfig
register: _result_cluster_kubeconfig
delegate_to: "{{ kubeinit_first_controller_node }}"

- name: Create kube directory
Expand All @@ -27,21 +27,21 @@
mode: '0644'
delegate_to: "{{ kubeinit_provision_service_node }}"

- name: Storing the master kubeconfig to the provision services machine.
- name: Store the kubeconfig to the provision services machine.
ansible.builtin.copy:
content: "{{ kubeinit_eks_cluster_kubeconfig.content | default('Empty file') | b64decode }}"
content: "{{ _result_cluster_kubeconfig.content | default('Empty file') | b64decode }}"
dest: ~/.kube/config
mode: '0644'
delegate_to: "{{ kubeinit_provision_service_node }}"

- name: Label worker nodes
- name: Label compute nodes
ansible.builtin.shell: |
kubectl label node {{ item }}.{{ kubeinit_cluster_fqdn }} node-role.kubernetes.io/worker=
kubectl label node {{ hostvars[item].fqdn }} node-role.kubernetes.io/worker=
args:
executable: /bin/bash
changed_when: false
with_items:
- "{{ groups['all_compute_nodes'] | list }}"
register: _result
changed_when: "_result.rc == 0"
loop: "{{ groups['all_compute_nodes'] }}"
delegate_to: "{{ kubeinit_provision_service_node }}"

- name: Deploy EKS manifests.
Expand All @@ -52,7 +52,8 @@
kubectl get release kubernetes-1-18-eks-1 -o yaml
args:
executable: /bin/bash
changed_when: false
register: _result
changed_when: "_result.rc == 0"
delegate_to: "{{ kubeinit_provision_service_node }}"

#
Expand Down
39 changes: 33 additions & 6 deletions kubeinit/roles/kubeinit_eks/tasks/prepare_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
kubeinit_deployment_pod_name: "{{ hostvars[kubeinit_provision_service_node].guest_name }}-pod"
kubeinit_deployment_delegate: "{{ hostvars[kubeinit_provision_service_node].target }}"
kubeinit_deployment_os: "{{ hostvars[kubeinit_provision_service_node].os }}"
kubeinit_deployment_type: container
kubeinit_deployment_role: provision

- name: Configure the service node
block:
Expand Down Expand Up @@ -72,6 +70,34 @@
# Kubernetes config
#

- name: Set EKS kubernetes major-minor fact
ansible.builtin.set_fact:
kubeinit_eks_kubernetes_major_minor: "{{ kubeinit_inventory_kubernetes_version.split('.')[0] + '-' + kubeinit_inventory_kubernetes_version.split('.')[1] }}"

- name: Discover the revision number for eks
ansible.builtin.command: curl -s https://raw.githubusercontent.com/aws/eks-distro/main/release/{{ kubeinit_eks_kubernetes_major_minor }}/production/RELEASE
register: _result_revision
changed_when: "_result_revision.rc == 0"

- name: Set EKS release number fact
ansible.builtin.set_fact:
kubeinit_eks_revision: "{{ _result_revision.stdout | trim }}"

- name: Discover the git tag for eks
ansible.builtin.command: curl -s https://raw.githubusercontent.com/aws/eks-distro/main/projects/kubernetes/release/{{ kubeinit_eks_kubernetes_major_minor }}/GIT_TAG
register: _result_gittag
changed_when: "_result_gittag.rc == 0"

- name: Set EKS string facts
ansible.builtin.set_fact:
kubeinit_eks_kubernetes_dirname: "kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}"
kubeinit_eks_kubernetes_filename: "kubernetes-{{ kubeinit_eks_kubernetes_major_minor + '-eks-' + kubeinit_eks_revision }}.yaml"
kubeinit_eks_kubernetes_gittag: "{{ (_result_gittag.stdout | trim) + '-eks-' + kubeinit_eks_kubernetes_major_minor + '-' + kubeinit_eks_revision }}"

- name: Set complete EKS kubernetes version
ansible.builtin.set_fact:
kubeinit_eks_kubernetes_version: "{{ kubeinit_inventory_kubernetes_version + '.' + kubeinit_eks_revision }}"

- name: Install requirements
ansible.builtin.command: dnf install -y kubectl-{{ kubeinit_eks_kubernetes_version }} --disableexcludes=kubernetes

Expand All @@ -92,10 +118,11 @@

- name: Get the required container images
ansible.builtin.shell: |
set -o pipefail
curl -s https://distro.eks.amazonaws.com/kubernetes-1-21/kubernetes-1-21-eks-4.yaml | sed -n -e "s|^.*uri: \(public.ecr.aws/eks-distro\)|\1|p" > ~/kubeinit_deployment_images.txt
echo public.ecr.aws/eks-distro/kubernetes/kube-proxy-base:$(curl -s https://raw.githubusercontent.com/aws/eks-distro/main/projects/kubernetes/release/1-21/GIT_TAG)-eks-1-21-4 >> ~/kubeinit_deployment_images.txt
echo public.ecr.aws/eks-distro/kubernetes/go-runner:$(curl -s https://raw.githubusercontent.com/aws/eks-distro/main/projects/kubernetes/release/1-21/GIT_TAG)-eks-1-21-4 >> ~/kubeinit_deployment_images.txt
set -eo pipefail
curl -s https://distro.eks.amazonaws.com/{{ kubeinit_eks_kubernetes_dirname }}/{{ kubeinit_eks_kubernetes_filename }} | \
sed -n -e "s|^.*uri: \(public.ecr.aws/eks-distro\)|\1|p" > ~/kubeinit_deployment_images.txt
echo public.ecr.aws/eks-distro/kubernetes/kube-proxy-base:{{ kubeinit_eks_kubernetes_gittag }} >> ~/kubeinit_deployment_images.txt
echo public.ecr.aws/eks-distro/kubernetes/go-runner:{{ kubeinit_eks_kubernetes_gittag }} >> ~/kubeinit_deployment_images.txt
args:
executable: /bin/bash
register: _result
Expand Down
12 changes: 3 additions & 9 deletions kubeinit/roles/kubeinit_k8s/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
vars:
kubeinit_deployment_node_name: "{{ cluster_role_item }}"
kubeinit_deployment_delegate: "{{ hostvars[cluster_role_item].target }}"
kubeinit_deployment_role: cluster
when: kubeinit_cluster_nodes_deployed is not defined or not kubeinit_cluster_nodes_deployed

- name: Setup the first controller node
Expand Down Expand Up @@ -173,18 +172,13 @@

# The kubeconfig file is on the controller nodes so we run kubectl label on the first controller
- name: Label node
ansible.builtin.shell: |
kubectl label node {{ kubeinit_deployment_node_name }}.{{ kubeinit_cluster_fqdn }} node-role.kubernetes.io/worker=
args:
executable: /bin/bash
ansible.builtin.command: |
kubectl label node {{ hostvars[compute_node].fqdn }} node-role.kubernetes.io/worker=
register: _result
changed_when: "_result.rc == 0"
loop: "{{ groups['all_compute_nodes'] }}"
loop_control:
loop_var: cluster_role_item
vars:
kubeinit_deployment_node_name: "{{ cluster_role_item }}"
kubeinit_deployment_role: compute
loop_var: compute_node
delegate_to: "{{ kubeinit_first_controller_node }}"

- name: Add task-deploy-cluster to tasks_completed
Expand Down
4 changes: 2 additions & 2 deletions kubeinit/roles/kubeinit_k8s/tasks/post_deployment_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- name: Copying the kubeconfig to a variable
ansible.builtin.slurp:
src: ~/.kube/config
register: kubeinit_k8s_cluster_kubeconfig
register: _result_cluster_kubeconfig
delegate_to: "{{ kubeinit_first_controller_node }}"

- name: Create kube directory
Expand All @@ -30,7 +30,7 @@

- name: Storing the master kubeconfig to the services machine.
ansible.builtin.copy:
content: "{{ kubeinit_k8s_cluster_kubeconfig.content | default('Empty file') | b64decode }}"
content: "{{ _result_cluster_kubeconfig.content | default('Empty file') | b64decode }}"
dest: ~/.kube/config
mode: '0644'
delegate_to: "{{ kubeinit_provision_service_node }}"
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_k8s/tasks/prepare_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
kubeinit_deployment_pod_name: "{{ hostvars[kubeinit_provision_service_node].guest_name }}-pod"
kubeinit_deployment_delegate: "{{ hostvars[kubeinit_provision_service_node].target }}"
kubeinit_deployment_os: "{{ hostvars[kubeinit_provision_service_node].os }}"
kubeinit_deployment_type: container
kubeinit_deployment_role: provision

- name: Configure the service node
block:
Expand Down
2 changes: 1 addition & 1 deletion kubeinit/roles/kubeinit_kid/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
vars:
kubeinit_deployment_node_name: "{{ cluster_node }}"
kubeinit_deployment_delegate: "{{ hostvars[cluster_node].target }}"
kubeinit_deployment_role: cluster
when: kubeinit_cluster_nodes_deployed is not defined or not kubeinit_cluster_nodes_deployed

- name: Add cluster authorized keys in all cluster nodes
ansible.posix.authorized_key:
Expand Down
4 changes: 2 additions & 2 deletions kubeinit/roles/kubeinit_kid/tasks/post_deployment_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
touch ~/.kube/config
args:
executable: /bin/bash
register: touch_kubeconfig
changed_when: "touch_kubeconfig.rc == 0"
register: _result
changed_when: "_result.rc == 0"
delegate_to: "{{ kubeinit_provision_service_node }}"
Loading

0 comments on commit 62465ab

Please sign in to comment.