Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,62 @@
#
- role:
installDocker
when:
- computeInstall == 1
become: true
#
- role:
installKubernetes
when:
- computeInstall == 1
become: true
#
- role:
installHelm
when:
- computeInstall == 1
- computeNodeType == "controlPlane"
become: true
#
- role:
setupKubernetesControlPlane
when:
- computeInstall == 1
- computeNodeType == "controlPlane"
become: true
#
- role:
setupKubernetesWorker
when:
- computeInstall == 1
- computeNodeType == "worker"
become: true
#
- role:
setupNetworkFileSystemServer
when:
- computeInstall == 1
- computeNodeType == "controlPlane"
become: true
#
- role:
setupNetworkFileSystemClient
when:
- computeInstall == 1
- computeNodeType != "controlPlane"
become: true
#
- role:
configureKubernetes
when:
- computeInstall == 1
- computeNodeType == "controlPlane"
become: false
#
- role:
kubernetesCreate
installLinkerd
when:
- computeInstall == 1
- computeNodeType == "controlPlane"
become: false
#
Expand All @@ -122,6 +133,13 @@
when:
- computeNodeType == "controlPlane"
become: false
#
- role:
kubernetesCreate
when:
- computeNodeType == "controlPlane"
become: false

#
post_tasks:
#
Expand Down
56 changes: 52 additions & 4 deletions ansible/roles/configureKubernetes/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
when:
- taskResponse.rc == 0
#
- name: Set Kubernetes node label
- name: Set Kubernetes node label(system)
ansible.builtin.command:

#cmd: " kubectl label node $HOSTNAME system=secondOne"
Expand Down Expand Up @@ -167,9 +167,57 @@
#
when:
- taskResponse.rc != 0



#######################################################################################################################
# LAB 12.1: Assign Pods Using Labels
#######################################################################################################################
- name: Get a list of kubernetes worker nodes
ansible.builtin.shell:
# NOTE: A folding block operator joins multiple lines together by spaces
cmd: >
kubectl get nodes
| grep -v 'control-plane'
| grep -Eo '^([^ ]+)'
#
register: workerNodes
#
- name: Set Kubernetes node label(status)
ansible.builtin.command:
cmd: "kubectl label node {{ item }} status=other --overwrite=true"
#
with_items: "{{ workerNodes.stdout_lines | reverse | list | first }}"
when:
- workerNodes.rc == 0
#
- name: Get a list of kubernetes control-plane nodes
ansible.builtin.shell:
# NOTE: A folding block operator joins multiple lines together by spaces
cmd: >
kubectl get nodes
| grep 'control-plane'
| grep -Eo '^([^ ]+)'
#
register: controlPlanNodes
#
- name: Set Kubernetes node label(status)
ansible.builtin.command:
cmd: "kubectl label node {{ item }} status=vip --overwrite=true"
#
with_items: "{{ controlPlanNodes.stdout_lines | first }}"
when:
- controlPlanNodes.rc == 0
#
- name: Get Kubernetes node labels
ansible.builtin.command:
cmd: "kubectl get nodes --show-labels"
#
register: taskResponse
#
- name: Log Kubernetes node labels
ansible.builtin.debug:
var: taskResponse.stdout_lines
#######################################################################################################################
#
#######################################################################################################################

#
...
Expand Down
25 changes: 25 additions & 0 deletions ansible/roles/configureKubernetes/templates/kubectl-DevDan.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1EVXdNakUzTURnMU5Wb1hEVE15TURReU9URTNNRGcxTlZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTFFSClRybTJ2bHE4SEl3SzdoT1FaQnY1OXF0MVNkcDl3QjR4KzFmMVpQUWNuSWxrWStOSW5pR1QyUzdFT3NvSW5RTXAKVEcwVFFoeEpDcGxvSzYzTitmb24zQzVYckJSeXdGaXVtVWkxZ2NRS2Fs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:
cluster: kubernetes
namespace: development
user: DevDan
name: DevDan-context
- context:
cluster: kubernetes
namespace: production
user: DevDan
name: ProdDan-context
current-context: DevDan-context
kind: Config
preferences: {}
users:
- name: DevDan
user:
client-certificate: /home/DevDan/DevDan.crt
client-key: /home/DevDan/DevDan.key
64 changes: 63 additions & 1 deletion ansible/roles/helmChart/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@
#BOF
---
#######################################################################################################################
#
# Shared setup
#######################################################################################################################
#
- name: Retrieve non-root user environment
ansible.builtin.shell:
cmd: set
#
register: taskResponse
no_log: true
#
- name: Setup home dir variable
ansible.builtin.set_fact:
userHomeDir: "{{ item | regex_search( userHomeDirRegex, '\\1' ) | first | string }}"
#
with_items: "{{ taskResponse.stdout_lines }}"
when:
- item | regex_search( '^HOME=' )
no_log: true
#######################################################################################################################
# LAB :
#######################################################################################################################
#
- name: Add helm repo
Expand All @@ -30,6 +49,49 @@
- name: Log helm install
ansible.builtin.debug:
var: taskResponse.stdout_lines
#######################################################################################################################
# LAB 11.2: Ingress Controller
#######################################################################################################################
#
- name: Add helm repo[{{ ingressRepoName }}]
ansible.builtin.shell:
cmd:
helm repo add {{ ingressRepoName }} {{ ingressRepoUrl }}
#
- name: Update helm repo
ansible.builtin.shell:
cmd:
helm repo update
#
- name: Recursively remove {{ ingressName }} directory
ansible.builtin.file:
path: "{{ '%s/%s' | format( userHomeDir, ingressName ) }}"
state: absent
#
ignore_errors: true
#
- name: helm fetch[{{ ingressRepoName }}/{{ ingressName }}]
ansible.builtin.shell:
cmd:
helm fetch {{ ingressRepoName }}/{{ ingressName }} --untar
#
- name: Create helm values.yaml file[{{ ingressName }}]
ansible.builtin.template:
src: "{{ '%s.j2' | format( ingressHelmValueFile ) }}"
dest: "{{ '%s/%s/values.yaml' | format( userHomeDir, ingressName ) }}"
# NOTE: /usr/bin/chmod modes are actually octal numbers
mode: 0644
#
- name: helm install[{{ ingressHelmName }}]
ansible.builtin.shell:
cmd:
cd {{ ingressName }} ; helm upgrade --install {{ ingressHelmName }} .
#
register: taskResponse
#
- name: Log helm install[{{ ingressHelmName }}]
ansible.builtin.debug:
var: taskResponse.stdout_lines
#
...
#EOF
Loading