deploy mongodb database
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
######################################
|
||||
# add controller to existing cluster #
|
||||
######################################
|
||||
---
|
||||
- name: copy clusterConfig to remote location
|
||||
template:
|
||||
src: '../templates/k8s_cluster/cluster/joinController.yml.j2'
|
||||
dest: /tmp/joinController.yml
|
||||
|
||||
- name: Join the controller node to cluster
|
||||
command: kubeadm join --config=/tmp/joinController.yml
|
||||
|
||||
- name: Setup kubeconfig for local usage
|
||||
command: "{{ item }}"
|
||||
loop:
|
||||
- mkdir -p ~/.kube
|
||||
- cp -i /etc/kubernetes/admin.conf ~/.kube/config
|
||||
@@ -1,12 +0,0 @@
|
||||
######################################
|
||||
# add worker to existing cluster #
|
||||
######################################
|
||||
---
|
||||
- name: Copy the worker join command to server location
|
||||
copy: src=join_command_worker.sh dest=/tmp/join_command_worker.sh mode=0777
|
||||
|
||||
- name: Join the worker node to cluster
|
||||
command: sh /tmp/join_command_worker.sh
|
||||
|
||||
- name: Delete local copy of join worker
|
||||
local_action: file path=./join_command_worker.sh state=absent
|
||||
@@ -1,28 +0,0 @@
|
||||
######################################
|
||||
# Tasks for init k8s cluster #
|
||||
######################################
|
||||
---
|
||||
- name: Generate join command
|
||||
command: kubeadm token create --print-join-command
|
||||
register: join_command
|
||||
|
||||
- name: Copy join command to local file
|
||||
local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="./join_command_worker.sh"
|
||||
|
||||
- name: Generate join command controller token
|
||||
command: kubeadm token create
|
||||
register: join_command_token
|
||||
|
||||
- name: Generate join command controller certsKey
|
||||
command: kubeadm init phase upload-certs --upload-certs
|
||||
register: join_command_controller_certskey
|
||||
|
||||
- name: Generate join command controller certssh256
|
||||
shell: openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
|
||||
register: join_command_controller_certsha256
|
||||
|
||||
- name: save facts for controller join
|
||||
set_fact:
|
||||
token: '{{ join_command_token.stdout }}'
|
||||
certskey: '{{ join_command_controller_certskey.stdout_lines[-1] }}'
|
||||
certsha256: '{{ join_command_controller_certsha256.stdout }}'
|
||||
@@ -1,69 +0,0 @@
|
||||
######################################
|
||||
# Tasks for init k8s cluster #
|
||||
######################################
|
||||
---
|
||||
- name: Get hostname
|
||||
command: hostname
|
||||
register: old_hostname
|
||||
changed_when: false
|
||||
|
||||
- set_fact: hostname={{ old_hostname.stdout | lower }}
|
||||
|
||||
- name: Pull k8s images
|
||||
command: kubeadm config images pull --kubernetes-version=v{{ kubernetesVersion }}
|
||||
|
||||
- name: copy clusterConfig to remote location
|
||||
template:
|
||||
src: '../templates/k8s_cluster/cluster/clusterConfiguration.yml.j2'
|
||||
dest: /tmp/clusterConfiguration.yml
|
||||
|
||||
- name: Initialize the Kubernetes cluster using kubeadm
|
||||
command:
|
||||
argv:
|
||||
- kubeadm
|
||||
- init
|
||||
- --config=/tmp/clusterConfiguration.yml
|
||||
- --node-name={{ hostname }}
|
||||
- --ignore-preflight-errors
|
||||
- Swap
|
||||
- --upload-certs
|
||||
|
||||
- name: Remove clusterConfig on remote location
|
||||
ansible.builtin.file:
|
||||
path: /tmp/clusterConfiguration.yml
|
||||
state: absent
|
||||
|
||||
- name: Setup kubeconfig for local usage
|
||||
command: "{{ item }}"
|
||||
loop:
|
||||
- mkdir -p ~/.kube
|
||||
- cp -i /etc/kubernetes/admin.conf ~/.kube/config
|
||||
|
||||
- name: Wait for all k8s nodes to be ready
|
||||
shell: kubectl wait --for=condition=Ready nodes --all --timeout=600s
|
||||
register: nodes_ready
|
||||
|
||||
- name: create Calico NetworkManager directory
|
||||
file:
|
||||
path: '/etc/NetworkManager/conf.d/'
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Configure Calico NetworkManager
|
||||
template:
|
||||
src: ../templates/k8s_cluster/cluster/calico.conf.j2
|
||||
dest: /etc/NetworkManager/conf.d/calico.conf
|
||||
owner: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Install calico pod network
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition: "{{ lookup('template', '../templates/k8s_cluster/cluster/calico.yml.j2') | from_yaml_all }}"
|
||||
|
||||
- name: Wait for calico daemonset become ready
|
||||
command: "kubectl rollout status daemonset calico-node -n kube-system --timeout 60s"
|
||||
|
||||
- name: Generate join command
|
||||
command: kubeadm token create --print-join-command
|
||||
register: join_command
|
||||
@@ -1,9 +0,0 @@
|
||||
########################################
|
||||
#Restart DNS after DeamonSet Deployment#
|
||||
########################################
|
||||
---
|
||||
- name: Wait for calico pods become ready
|
||||
command: "kubectl rollout status daemonset calico-node -n kube-system --timeout 120s"
|
||||
|
||||
- name: Restart CoreDNS deployment
|
||||
command: "kubectl rollout restart deployments/coredns -n kube-system"
|
||||
Reference in New Issue
Block a user