Skip to content

Commit 0c68ce1

Browse files
committed
add getting-started doc
1 parent cb08d1d commit 0c68ce1

3 files changed

Lines changed: 431 additions & 6 deletions

File tree

content/en/docs/getting-started/#kahuna-setup.md#

Lines changed: 0 additions & 6 deletions
This file was deleted.

content/en/docs/getting-started/kahuna-setup.md

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,284 @@ title: Setup Kahuna
33
description: Let's start with the orchestration core
44
weight: 3
55
---
6+
7+
Now let's suppose that you've cloned the Git platform repository template and that your **Kahuna** instance server has been provisioned with latest Ubuntu LTS distribution. Be sure that it is SSH-accessible with some local user.
8+
9+
Let's take the following assumptions for the rest of this tutorial:
10+
11+
- We only have one single **Kahuna** instance (no high-availability).
12+
- Local bootstrap user with **sudo** privileges is *ubuntu*, with key-based SSH authentication.
13+
- **Kahuna** instance is public-Internet exposed through IP address *1.2.3.4*, translated to *kowabunga.acme.com* DNS.
14+
- **Kahuna** instance is private-network exposed through IP address *10.0.0.1*.
15+
- **Kahuna** instance hostname is **kowabunga-kahuna-1**.
16+
17+
## Setup DNS
18+
19+
Please ensure that your *kowabunga.acme.com* domain translates to public IP address *1.2.3.4*. Configuration is up to you and your DNS provider and can be done manually.
20+
21+
Being IaC-supporters, we advise using OpenTofu for that purpose. Let's see how we can do, using Cloudflare DNS provider.
22+
23+
Start by editing the **terraform/providers.tf** file in your platform's repository:
24+
25+
```hcl
26+
terraform {
27+
required_providers {
28+
cloudflare = {
29+
source = "cloudflare/cloudflare"
30+
version = "~> 5"
31+
}
32+
}
33+
}
34+
35+
provider "cloudflare" {
36+
api_token = local.secrets.cloudflare_api_token
37+
}
38+
```
39+
40+
extend the **terraform/secrets.tf** file with:
41+
42+
```hcl
43+
locals {
44+
secrets = {
45+
cloudflare_api_token = data.sops_file.secrets.data.cloudflare_api_token
46+
}
47+
}
48+
```
49+
50+
and add the associated:
51+
52+
```yaml
53+
cloudflare_api_token: MY_PREVIOUSLY_GENERATED_API_TOKEN
54+
```
55+
56+
variable in **terraform/secrets.yml** file thanks to:
57+
58+
```sh
59+
$ kobra secrets edit terraform/secrets.yml
60+
```
61+
62+
Then, simply edit your **terraform/main.tf** file with the following:
63+
64+
```hcl
65+
resource "cloudflare_dns_record" "kowabunga" {
66+
zone_id = "ACME_COM_ZONE_ID"
67+
name = "kowabunga"
68+
ttl = 3600
69+
type = "A"
70+
content = "1.2.3.4"
71+
proxied = false
72+
}
73+
```
74+
75+
and run OpenTofu through:
76+
77+
```sh
78+
$ kobra tf apply
79+
```
80+
81+
## Inventory Management
82+
83+
It is now time to declare your **Kahuna** instance in Ansible's inventory. Simply extend the **ansible/inventories/hosts.txt** the following way:
84+
85+
```ini
86+
[kahuna]
87+
10.0.0.1 name=kowabunga-kahuna-1 ansible_ssh_user=ubuntu
88+
```
89+
90+
The instance is now declared to be part of **kahuna** group and Ansible will use **ubuntu** local user account to connect through SSH.
91+
92+
Note that doing so, you can now safely:
93+
94+
- declare host-specific variables in **ansible/host_vars/10.0.0.1.yml** file.
95+
- declare host-specific sensitive variables in **ansible/host_vars/10.0.0.1.sops.yml** file.
96+
- declare **kahuna** group-specific variables in **ansible/group_vars/kahuna/main.yml** file.
97+
- declare **kahuna** group-specific sensitive variables in **ansible/group_vars/kahuna.sops.yml** file.
98+
- declare any other global variables in **ansible/group_vars/all/main.yml** file.
99+
- declare any other global sensitive variables in **ansible/group_vars/all.sops.yml** file.
100+
101+
Note that Ansible variables precedence will apply:
102+
103+
```txt
104+
role defaults < all vars < group vars < host vars < role vars
105+
```
106+
107+
## Ansible Kowabunga Collection
108+
109+
Kowabunga comes with an official [Ansible Collection](https://galaxy.ansible.com/ui/repo/published/kowabunga/cloud/) and its associated [documentation](https://ansible.kowabunga.cloud/kowabunga/cloud/index.html#plugins-in-kowabunga-cloud).
110+
111+
The collection contains:
112+
113+
- **roles** and **playbooks** to easily deploy the various [Kahuna](/docs/concepts/kahuna/), [Koala](/docs/concepts/koala/), [Kiwi](/docs/concepts/kiwi/) and [Kaktus](/docs/concepts/kaktus/) instances.
114+
- **actions** so you can create your own tasks to interact and manage a previously setup Kowabunga instance.
115+
116+
Check out **ansible/requirements.yml** file to declare the specific collection version you'd like to use:
117+
118+
```yaml
119+
---
120+
collections:
121+
- name: kowabunga.cloud
122+
version: 0.0.1
123+
```
124+
125+
By default, your platform is configured to pull a tagged official release from Ansible Galaxy. You may however prefer to pull it directly from Git, using latest commit for instance. This can be accomodated through:
126+
127+
```yaml
128+
---
129+
collections:
130+
- name: git@github.com:kowabunga-cloud/ansible-collections-kowabunga
131+
type: git
132+
version: master
133+
```
134+
135+
Once defined, simply pull it into your local machine:
136+
137+
```sh
138+
$ kobra ansible pull
139+
```
140+
141+
## Kahuna Settings
142+
143+
**Kahuna** instance deployment will take care of everything. It'll take the assumption of running a supported Ubuntu LTS release, enforce some configuration and security settings, install the necessary packages, create local admin user accounts, if required, and setup some form of deny-all filtering policy firewall, so you're safely exposed.
144+
145+
### Admin Accounts
146+
147+
Let's start by declaring some user admin accounts we'd like to create. We don't want to keep on using the single nominative **ubuntu** account for everyone after all.
148+
149+
Simply create/edit the **ansible/inventories/group_vars/all/main.yml** file the following way:
150+
151+
```yaml
152+
kowabunga_os_user_admin_accounts_enabled:
153+
- admin_user_1
154+
- admin_user_2
155+
156+
kowabunga_os_user_admin_accounts_pubkey_dirs:
157+
- "{{ playbook_dir }}/../../../../../files/pubkeys"
158+
```
159+
160+
to declare all your expected admin users, and add their respective SSH public key files in the **ansible/files/pubkeys** directory, e.g.:
161+
162+
```sh
163+
$ tree ansible/files/pubkeys/
164+
ansible/files/pubkeys/
165+
└── admin_user_1
166+
└── admin_user_2
167+
```
168+
169+
{{< alert color="success" title="Note" >}}
170+
Note that all registered admin accounts will have password-less **sudo** privileges.
171+
{{< /alert >}}
172+
173+
We'd also recommend you to set/update the **root** account password. By default, Ubuntu comes without any, making it impossible to login. Kowabunga's playbook make sure that root login is prohibited from SSH for security reasons (e.g. brute-force attacks) but we encourage you setting one, as it's always useful, especially on public cloud VPS or bare metal servers to get a console/IPMI access to log into.
174+
175+
If you intend to do so, simply edit the secrets file:
176+
177+
```sh
178+
$ kobra secrets edit ansible/inventories/group_vars/all.sops.yml
179+
```
180+
181+
and set the requested password:
182+
183+
```yaml
184+
secret_kowabunga_os_user_root_password: MY_SUPER_SETRONG_PASSWORD
185+
```
186+
187+
### Firewall
188+
189+
If you **Kahuna** instance is connected on public Internet, it is more than recommended to enable a network firewall. This can be easily done by extending the **ansible/inventories/group_vars/kahuna/main.yml** file with:
190+
191+
```yaml
192+
kowabunga_firewall_enabled: true
193+
kowabunga_firewall_open_tcp_ports:
194+
- 22
195+
- 80
196+
- 443
197+
```
198+
199+
Note that we're limited opened ports to SSH and HTTP/HTTPS here, which should be more than enough (HTTP is only used by **Caddy** server for certificate auto-renewal and will redirect traffic to HTTPS anyway). If you don't expect your instance to be SSH-accessible on public Internet, you can safely drop this line.
200+
201+
### MongoDB
202+
203+
**Kahuna** comes with a bundled, ready-to-be-used **MongoDB** deployment. This comes in handy if you only have a unique instance to manage. This remains however optional (default), as you may very well be willing to re-use an existing external production-grade MongoDB cluster, already deployed.
204+
205+
If you intend to go with the bundled one, a few settings must be configured in **ansible/inventories/group_vars/kahuna/main.yml** file:
206+
207+
```yaml
208+
kowabunga_mongodb_enabled: true
209+
kowabunga_mongodb_listen_addr: "127.0.0.1,10.0.0.1"
210+
kowabunga_mongodb_rs_key: "{{ secret_kowabunga_mongodb_rs_key }}"
211+
kowabunga_mongodb_rs_name: kowabunga
212+
kowabunga_mongodb_admin_password: "{{ secret_kowabunga_mongodb_admin_password }}"
213+
kowabunga_mongodb_users:
214+
- base: kowabunga
215+
username: kowabunga
216+
password: '{{ secret_kowabunga_mongodb_user_password }}'
217+
readWrite: true
218+
```
219+
220+
and their associated secrets in **ansible/inventories/group_vars/kahuna.sops.yml**
221+
222+
```yaml
223+
secret_kowabunga_mongodb_rs_key: YOUR_CUSTOM_REPLICA_SET_KEY
224+
secret_kowabunga_mongodb_admin_password: A_STRONG_ADMIN_PASSWORD
225+
secret_kowabunga_mongodb_user_password: A_STRONG_USER_PASSWORD
226+
```
227+
228+
This will basically instruct Ansible to install MongoDB server, configure it with a replicaset (so it can be part of a future cluster instance, we never know), secure it with admin credentials of your choice and create a **kowabunga** database/collection and associated service user.
229+
230+
### Kahuna Settings
231+
232+
Finally, let's ensure the **Kahuna** orchestrator gets everything he needs to operate.
233+
234+
You'll need to define:
235+
236+
- a custom email address (and associated SMTP connection settings) for **Kahuna** to be able to send email notifications to users.
237+
- a randomly generated key to sign JWT tokens (please ensure it is secure enough, not to compromise issued tokens robustness).
238+
- a randomly generated admin API key. It'll be used to provision the admin bits of Kowabunga, until proper user accounts have been created.
239+
- a private/public SSH key-pair to be used by platform admins to seamlessly SSH into instantiated [Kompute](/docs/services/kompute/) instances. Please ensure that the private key is being stored securely somewhere.
240+
241+
Then simply edit the **ansible/inventories/group_vars/kahuna/main.yml** file the following way:
242+
243+
```yaml
244+
kowabunga_public_url: "https://kowabunga.acme.com"
245+
246+
kowabunga_kahuna_http_address: "10.0.0.1"
247+
kowabunga_kahuna_admin_email: kowabunga@acme.com
248+
kowabunga_kahuna_jwt_signature: "{{ secret_kowabunga_kahuna_jwt_signature }}"
249+
kowabunga_kahuna_db_uri: "mongodb://kowabunga:{{ secret_kowabunga_mongodb_user_password }}@10.0.0.1:{{ mongodb_port }}/kowabunga?authSource=kowabunga"
250+
kowabunga_kahuna_api_key: "{{ secret_kowabunga_kahuna_api_key }}"
251+
252+
kowabunga_kahuna_bootstrap_user: kowabunga
253+
kowabunga_kahuna_bootstrap_pubkey: "YOUR_ADMIN_SSH_PUB_KEY"
254+
255+
kowabunga_kahuna_smtp_host: "smtp.acme.com"
256+
kowabunga_kahuna_smtp_port: 587
257+
kowabunga_kahuna_smtp_from: "Kowabunga <{{ kowabunga_kahuna_admin_email }}>"
258+
kowabunga_kahuna_smtp_username: johndoe
259+
kowabunga_kahuna_smtp_password: "{{ secret_kowabunga_kahuna_smtp_password }}"
260+
```
261+
262+
and add the respective secrets into **ansible/inventories/group_vars/kahuna.sops.yml**:
263+
264+
```yaml
265+
secret_kowabunga_kahuna_jwt_signature: A_STRONG_JWT_SGINATURE
266+
secret_kowabunga_kahuna_api_key: A_STRONG_API_KEY
267+
secret_kowabunga_kahuna_smtp_password: A_STRONG_PASSWORD
268+
```
269+
270+
## Ansible Deployment
271+
272+
We're done with configuration (finally) ! All we need to do now is finally run Ansible to make things live. This is done by invoking the **kahuna** playbook from the **kowabunga.cloud** collection:
273+
274+
```sh
275+
$ kobra ansible deploy -p kowabunga.cloud.kahuna
276+
```
277+
278+
Note that, under-the-hood, Ansible will use [Ansible Mitogen extension](https://mitogen.networkgenomics.com/ansible_detailed.html) to speed things up. Bear in mind that Ansible's run is idempotent. Anything's failing can be re-executed. You can also run it as many times you want, or re-run it in the next 6 months or so, provided you're using a tagged collection, the end result will always be the same.
279+
280+
After a few minutes, if everything's went okay, you should have a working **Kahuna** instance, i.e.:
281+
282+
- A [Caddy](https://caddyserver.com/) frontal reverse-proxy, taking care of automatic TLS certificate issuance, renewal and traffic termination, forwarding requests back to either [Koala](/docs/concepts/koala/) Web application or [Kahuna](/docs/concepts/kahuna/) backend server.
283+
- The [Kahuna](/docs/concepts/kahuna/) backend server itself, our core orchestrator.
284+
- Optionally, [MongoDB](https://www.mongodb.com/) database.
285+
286+
We're now ready for [admin provisionning](/docs/getting-started/create-region/) !

0 commit comments

Comments
 (0)