Skip to content

Commit 487110e

Browse files
authored
Deployment: Add Ansible setup to deploy with microk8s (#296)
- adds an ansible/ directory for management deployments, starting with microk8s - has a microk8s role we will need to add workers - has a playbook with variables that can install most places
1 parent 2842ca6 commit 487110e

File tree

25 files changed

+1139
-0
lines changed

25 files changed

+1139
-0
lines changed

ansible/.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
root = true
2+
3+
# Defaults for all editor files
4+
[*]
5+
insert_final_newline = true
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
10+
# YAML is fussy about indenting and charset
11+
[*.yml]
12+
indent_style = space
13+
indent_size = 2
14+
continuation_indent_size = unset
15+
charset = utf-8
16+
17+
# Markdown is fussy about indenting
18+
[*.md]
19+
indent_style = space
20+
indent_size = 4
21+
22+
# Jinja2 template files
23+
[*.j2]
24+
end_of_line = lf

ansible/.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
direnv 2.32.1
2+
python 3.10.6

ansible/Pipfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
ansible = "==6.2.0"
8+
molecule = {extras = ["docker"], version = "==4.0.1"}
9+
certifi = "*"
10+
ansible-lint = "==6.4.0"
11+
yamllint = "==1.27.1"
12+
ansible-core = "==2.13"
13+
docker = "*"
14+
15+
[dev-packages]
16+
17+
[requires]
18+
python_version = "3.10"

ansible/Pipfile.lock

Lines changed: 636 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ansible/inventory/hosts.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.1.4 # ip address of your endpoint
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: install microk8s
3+
hosts: "{{ your_ip }}"
4+
remote_user: "{{ your_user }}"
5+
become: true
6+
roles:
7+
- role: ../roles/microk8s
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
skip_list:
3+
- ANSIBLE0002
4+
- ANSIBLE0006
5+
- ANSIBLE0010
6+
- ANSIBLE0016
7+
- '303'
8+
- '305'
9+
- '306'
10+
- '403'
11+
- '503'
12+
- '204'
13+
use_default_rules: true
14+
verbosity: 1

ansible/roles/microk8s/.yamllint

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# Based on ansible-lint config
3+
extends: default
4+
5+
ignore: |
6+
venv/
7+
.venv/
8+
9+
rules:
10+
braces:
11+
max-spaces-inside: 1
12+
level: error
13+
brackets:
14+
max-spaces-inside: 1
15+
level: error
16+
colons:
17+
max-spaces-after: -1
18+
level: error
19+
commas:
20+
max-spaces-after: -1
21+
level: error
22+
comments: disable
23+
comments-indentation: disable
24+
document-start: disable
25+
empty-lines:
26+
max: 3
27+
level: error
28+
hyphens:
29+
level: error
30+
indentation: disable
31+
key-duplicates: enable
32+
line-length: disable
33+
new-line-at-end-of-file: disable
34+
new-lines:
35+
type: unix
36+
trailing-spaces: disable
37+
truthy: disable

ansible/roles/microk8s/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Role Name
2+
=========
3+
4+
Installs and configures [MicroK8s](https://microk8s.io/)
5+
6+
Requirements
7+
------------
8+
9+
10+
Role Variables
11+
--------------
12+
13+
Add plugins you need installed with the following. (in the example below we are
14+
adding `istio`)
15+
16+
```yaml
17+
microk8s_plugins:
18+
istio: true # Core Istio service mesh services
19+
```
20+
21+
more information at [defaults/main.yml](defaults/main.yml)
22+
23+
You will want to make sure you add a value for `users` above. This will be the
24+
user that runs microk8s
25+
26+
Dependencies
27+
------------
28+
29+
The example here has been tested with Docker's Runtime
30+
31+
Example Playbook
32+
----------------
33+
34+
replace this with the IP address of your endpoint
35+
36+
```yaml
37+
---
38+
- name: install microk8s
39+
hosts: "{{ your_ip }}"
40+
remote_user: "{{ your_user }}"
41+
become: true
42+
roles:
43+
- role: ../roles/microk8s
44+
```
45+
License
46+
-------
47+
48+
ISC
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# defaults file for microk8s
3+
#
4+
# version management
5+
microk8s_version: "1.24/stable"
6+
microk8s_disable_snap_autoupdate: false
7+
8+
# plugin configuration
9+
microk8s_dns_resolvers: 149.112.112.112,9.9.9.9
10+
registry_size: 20Gi
11+
microk8s_plugins:
12+
dns: "{{ microk8s_dns_resolvers }}" # CoreDNS
13+
host-access: true # Allow Pods connecting to Host services smoothly
14+
ingress: true # Ingress controller for external access
15+
metrics-server: true # K8s Metrics Server for API access to service metrics
16+
rbac: true # Role-Based Access Control for authorisation
17+
storage: true # Storage class; allocates storage from host directory
18+
registry: "size={{ registry_size }}" # Private image registry exposed on localhost:32000
19+
dashboard: true # The Kubernetes dashboard
20+
gpu: false # Automatic enablement of Nvidia CUDA
21+
helm3: true # Helm 3 - Kubernetes package manager
22+
23+
helm3_repositories:
24+
- name: stable
25+
url: https://charts.helm.sh/stable
26+
27+
# users to make members of microk8s group
28+
users: []
29+
30+
# enable high-availability?
31+
microk8s_enable_ha: false
32+
33+
# hostgroup whose members will form high-availability cluster
34+
microk8s_group_ha: "microk8s_ha"
35+
36+
# regex to select IP address for joining nodes in HA setup
37+
microk8s_ip_regex_ha: "([0-9]{1,3}[\\.]){3}[0-9]{1,3}"

0 commit comments

Comments
 (0)