Erik is one of the founders of Instruqt, a learning platform for DevOps tooling and Cloud technology. With Instruqt, each participant gets his/her own personal infrastructure, that is being created in seconds. In this talk I will show how we leveraged Terraform, Kubernetes and Google Cloud to create a scalable and cost-effective learning platform. I will discuss the choices we've made, the problems we encountered and the lessons learned.
34. BEHIND THE SCENES
34
> PODSSERVICES
CONFIG
SECRETS
PROXY TRACK
NAMESPACE
OTHER INFRA
instruqt
35. Any container will work, platform
dependencies are injected at runtime.
BEHIND THE SCENES
35instruqt
36. # The volume is mounted in the pod from a git repository.
volume {
name = "bootstrap"
git_repo {
repository = "https://url-to-git-repo/bootstrap.git"
}
}
volume_mount {
name = "bootstrap"
mount_path = "/opt/bootstrap"
}
# Wait until the volume is mounted, then execute the setup script.
args = ["until [ -d /opt/bootstrap/ ]; do sleep 1; done;
/opt/bootstrap/setup.sh"]
36instruqt
37. Because terraform stores the state of
each user environment, cleanup is easy.
BEHIND THE SCENES
37instruqt
43. # The variables that need to go into the template.
data := struct {
Containers Container
}{ … }
# Create the destination file.
f, err := os.Create(outputPath)
# Parse the templates.
t := template.New(templateName)
_, err = t.ParseFiles(inputPath)
# Execute the template with the data.
for _, tmpl := range t.Templates() {
tmpl.ExecuteTemplate(f, tmpl.Name(), data)
}
43instruqt
44. # Loop over the containers in the config.yml file.
{{range .Containers}}
resource "kubernetes_replication_controller" "{{.Name}}" {
spec {
template {
container {
name = "{{.Name}}"
image = "{{.Image}}"
}
# Etc.
}
}
}
{{- end}}
44instruqt