Contenu connexe Plus de Martin Alfke (10) HashiTalksDACH-Terraform-Managing training instances in the Cloud1. © betadots GmbH 2022
Managing training instances
in the Cloud
HashiTalks DACH 15.09.22
Martin Alfke
ma@betadots.de
2. © betadots GmbH 2022
Martin Alfke
CEO betadots
• Puppet seit 2009
• Puppet Trainer seit 2011
• Linux, GitLab, Vagrant und Terraform
• tuxmea (Twitter, GitHub, Slack)
• Consulting, Training und Development
HashiTalks DACH 15.09.2022
About
2
3. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Unser Weg zur Cloud
• (Trainings-)Umgebung, Cloud und Automatisierung
• Cloud Automatisierung und Daten
• Unser nächsten Schritte
Agenda Tag 1
3
4. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
4
(Trainings-)Umgebung,
Cloud und Automatisierung
5. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Wann und wie Cloud?
(Trainings-)Umgebung, Cloud und Automatisierung
5
• Start mit Vagrant Instanzen (lokal, Laptop)
• Unterschiedliche Infrastruktur, je nach Training
• Wahl zwischen gehostetem Server oder Cloud
• Training braucht individuelles Setup
• Training hat vorhersagbare Laufzeit
• Abschätzung Aufwand Server <-> Cloud
6. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Unsere ersten Schritte
(Trainings-)Umgebung, Cloud und Automatisierung
6
• Wahl des Cloud Providers, Wahl des Netzwerkes
• Setup eines Trainings hart codiert (VM Namen), IP-basiert
• Eine Datei (hcloud.tf), keine Variablen
• Provisioning mit remote-exec - bekanntes Verfahren
• Automatisierung mit Puppet - unsere Präferenz
7. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Unsere ersten Schritte
(Trainings-)Umgebung, Cloud und Automatisierung
7
resource "hcloud_server" "puppet" {
name = "puppet"
image = "centos-7"
server_type = "cx41"
ssh_keys = data.hcloud_ssh_keys.all_keys.ssh_keys.*.name
location = “fsn1"
…
}
8. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
8
Cloud Automatisierung
und Daten
9. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Warum Daten?
Cloud Automatisierung und Daten
9
• Jedes Training ist anders in Hinsicht auf das Setup
• Puppet Open Source/Enterprise, GitLab, ELK, ...
• Möglichkeit mehrere Trainings parallel laufen zu lassen
• DNS Subdomain pro Training (einfacher zu merken als IP)
• Individuelle Trainings/Demos(pro Trainer/Consultant)
10. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Was sind Daten?
Cloud Automatisierung und Daten
10
• Cloud Provider- und DNS-Tokens
• DNS Subdomain
• Network CIDR, Zone
• SSH Deploy Keys
• GIT Repo und Branch
• SW Components und Versionen (Puppet 5,6,7, PE, ...)
• VMs, wie viele, welche Size?
11. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Strukturierte Daten!
Cloud Automatisierung und Daten
11
• Umbau hcloud.tf
• Verwendung HCL2: for_each Loops
• VMs als Hash
• Name
• IP
• Rolle (Setup)
• VM Sizing (S,M,L,XL - Cloud Provider abhängig)
• Deployment Reihenfolge
• variables.tf zur Datenvalidierung
12. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
HCL2 - Loops
Cloud Automatisierung und Daten
12
resource "hcloud_server" "client_nodes" {
for_each = var.machines
name = "${each.key}.${var.internal_subdomain}.${var.domain}"
image = each.value.image
server_type = each.value.server_type
ssh_keys = data.hcloud_ssh_keys.all_keys.ssh_keys.*.name
location = "fsn1" # nbg1, fsn1, hel1 or ash
…
}
13. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
variables.tf
Cloud Automatisierung und Daten
13
variable "machines" {
type = map
description = "Hash of IP, Role, HW size."
default = {
"puppet" = { ip = "10.0.1.1", role = "puppet", server_type = "cx41", image = "centos-7
"gitlab" = { ip = "10.0.1.2", role = "gitlab", server_type = "cx31", image = "centos-7", o
"login" = { ip = "10.0.1.3", role = "guacamole", server_type = "cx21", image = "centos
"runner" = { ip = "10.0.1.4", role = "runner", server_type = "cx21", image = "centos-7"
"student1" = { ip = "10.0.1.11", role = "webserver", server_type = "cx11", image = "cen
}
}
14. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
14
Unsere nächsten
Schritte
15. © betadots GmbH 2022
HashiTalks DACH 15.09.2022
Best Practices und multi-Cloud
Unsere nächsten Schritte
15
• Wechsel zu terraform Best Practice
• Verwendung von cloud-init anstelle remote-exec
• Möglichkeit den Cloud Provider zu wechseln (Hetzner, Azure, ...)
• Schnelleres Setup und Finalisieren
• Reduzierung manueller Schritte (hier vor allem GitLab Setup und
Access Control)
16. © betadots GmbH 2022
Vielen Dank für
Ihre Aufmerksamkeit!
Managing training instances
in the Cloud
Martin Alfke
ma@betadots.de