Skip to content

Commit

Permalink
add kong installation via Ansible
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Ferino committed Mar 30, 2024
1 parent 829ee89 commit aa420d3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ __pycache__/
.mypy_cache

.vagrant
.log
*.log
62 changes: 55 additions & 7 deletions local_infra/ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,69 @@ Execute o seguinte comando:
```bash
$ ansible-playbook -i ./inventory/localhost/hosts.yaml ./playbooks/main.yaml

PLAY [localhost] ***********************************************************************************
PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *****************************************************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Update package cache] ************************************************************************
TASK [Update package cache] ****************************************************
changed: [localhost]

TASK [Upgrade all packages] ************************************************************************
TASK [Upgrade all packages] ****************************************************
ok: [localhost]

TASK [Install MicroK8s] ****************************************************************************
TASK [Install prerequisites for MicroK8s] **************************************
ok: [localhost] => (item=curl)
ok: [localhost] => (item=iptables)
ok: [localhost] => (item=snapd)

TASK [Install MicroK8s] ********************************************************
changed: [localhost]

TASK [Check MicroK8s status] ***************************************************
changed: [localhost]

TASK [Create .kube directory] **************************************************
ok: [localhost]

TASK [Checking if the group exists] ********************************************
ok: [localhost]

TASK [Add Ansible user to microk8s group] **************************************
ok: [localhost]

TASK [Change ownership to Ansible user (and group)] ****************************
ok: [localhost]

TASK [Add kubectl and helm aliases] ********************************************
ok: [localhost] => (item={'alias': 'kubectl', 'command': 'microk8s kubectl'})
ok: [localhost] => (item={'alias': 'helm', 'command': 'microk8s helm'})

TASK [Enable add-ons] **********************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************
localhost : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
TASK [Instal Metallb] **********************************************************
changed: [localhost]

TASK [Install Kubernetes Gateway API] ******************************************
changed: [localhost]

TASK [Install Kubernetes Gateway CRD] ******************************************
changed: [localhost]

TASK [Add Kong helm repo] ******************************************************
changed: [localhost]

TASK [Update Helm repo] ********************************************************
changed: [localhost]

TASK [Check if the Kong namespace exists] **************************************
changed: [localhost]

TASK [Install KIC Helm] ********************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=18 changed=10 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0

```
31 changes: 29 additions & 2 deletions local_infra/ansible/playbooks/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,38 @@
line: 'alias {{ item.alias }}="{{ item.command }}"'
create: yes
become: true
with_items: "{{ bash_aliases }}"

with_items: "{{ bash_aliases }}"
- name: Enable add-ons
command: microk8s enable dns storage rbac

- name: Instal Metallb
command: microk8s enable metallb:{{ metallb_ip_range }}
become: true

- name: Install Kong Ingress Controller (KIC)
block:
- name: Install Kubernetes Gateway API
command: microk8s.kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml

- name: Install Kubernetes Gateway CRD
command: microk8s.kubectl apply -f /home/vagrant/kong/gateway-api-crd.yaml

- name: Add Kong helm repo
command: microk8s.helm repo add kong https://charts.konghq.com

- name: Update Helm repo
command: microk8s.helm repo update

- name: Check if the Kong namespace exists
command: microk8s.kubectl get namespace kong
ignore_errors: true
register: namespace_kong_output

- name: Install KIC Helm
command: microk8s.helm install kong kong/ingress -n kong --create-namespace
when: namespace_kong_output.rc != 0

become: true


Empty file.

0 comments on commit aa420d3

Please sign in to comment.