1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.4 KiB
Ruby

if ENV['GCE_PROJECT'] && ENV['GCE_DOMAIN'] && ENV['DNS_EMAIL'] && ENV['GCE_REGION']
if !File.exist?('traefik-service-account.json')
puts "File traefik-service-account.json is missing"
exit 1
end
if !File.exist?('traefik.htpass')
puts "File traefik.htpass is missing"
exit 1
end
puts "Get credentials"
system("gcloud container clusters get-credentials app-cluster --region #{ENV['GCE_REGION']}")
puts "Create namespace in cluster"
system("HTTPS_PROXY=localhost:8888 kubectl create namespace traefik")
puts "Handle the custom resource definitions"
system("HTTPS_PROXY=localhost:8888 kubectl apply -f crd.yml")
puts "Handle the Role-Based Access Control needed by traefik"
system("HTTPS_PROXY=localhost:8888 kubectl apply -f rbac.yml")
puts "Create kubernetes secrets for traefik"
system("HTTPS_PROXY=localhost:8888 kubectl create secret generic traefik-auth --from-file traefik.htpass --namespace=traefik")
system("HTTPS_PROXY=localhost:8888 kubectl create secret generic traefik-service-account --from-file=traefik-service-account.json=traefik-service-account.json --namespace=traefik")
puts "Deploy traefik itself"
system("envsubst < deployment_base.yml > deployment.yml")
system("HTTPS_PROXY=localhost:8888 kubectl apply -f deployment.yml")
else
puts "Missing env vars, did you define GCE_PROJECT, GCE_DOMAIN, GCE_REGION and DNS_EMAIL ?"
exit 1
end