Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable https and ambassador routing #80

Merged
merged 1 commit into from Jun 1, 2021
Merged

Enable https and ambassador routing #80

merged 1 commit into from Jun 1, 2021

Conversation

ghost
Copy link

@ghost ghost commented May 5, 2021

Switches from nginx-ingress to Ambassador
Adds cert-manager for handling Let's Encrypt
Adds TLS termination
Grafana accessible with https://domain/grafana/

@msrn msrn added safe-to-test PR's that are safe to test with the pipeline and removed safe-to-test PR's that are safe to test with the pipeline labels May 5, 2021
@ghost
Copy link
Author

ghost commented May 5, 2021

FIRST
change email in tls.yaml to a real email
if multiple people are running clusters at the same time each has to have a unique DNS name label
change "smaddis" in mentions of "smaddis.westeurope.cloudapp.azure.com" in tls.yaml, ambassador_mappings.yaml and prom_values.yaml to something unique "foo"

Run terraform apply
When terraform is done run az aks get-credentials --resource-group barkuksatrng-k8stest-rg --name barkuksatrng-k8stest-cluster if needed
Run "kubectl get all"
Note external IP of Ambassador service
Navigate to Azure Portal -> Resource groups -> MC_barkuksatrng-k8stest-rg
-> Go through kubernetes-aXXXXXXXXXXXXXXXXXXXX until you find the one that has the same IP
as ambassador service
-> Select Configuration
-> Write "foo" (=unique thing you replaced it with) into DNS name label field and hit save
Run kubectl apply -f ambassador_mappings.yaml
Run kubectl apply -f tls.yaml
-> You should now be able to access grafana through URL https://foo.westeurope.cloudapp.azure.com/grafana/
jaeger through https://foo.westeurope.cloudapp.azure.com:16686

@ghost
Copy link
Author

ghost commented May 5, 2021

  1. Enter a real email in place of "[email protected]" in tls.yaml

  2. Ensure that you have a unique DNS name label, only one cluster can use the same name. Replace each "smaddis" in "smaddis.westeurope.cloudapp.azure.com" in files tls.yaml, ambassador_values.yaml and modules/container_deployment/prom_values.yaml with something unique "foo"


Set DNS name

After the cluster is ready,
0. Run

$ az aks get-credentials --resource-group barkuksatrng-k8stest-rg --name barkuksatrng-k8stest-cluster
  1. Run
$ kubectl get all
  1. Note the EXTERNAL-IP for service/ambassador
  2. Head over to Azure Portal -> Resource Groups
  3. Select your resource group MC_barkuksatrng-k8stest-...
  4. Check each "kubernetes-aXXXXXXXXXXXXXX" Public IP until you find the one for ambassador
  5. Select Configuration on the left menu
  6. Write your unique DNS name label foo and Save
  7. Perform
$ Run kubectl apply -f ambassador_mappings.yaml
$ Run kubectl apply -f tls.yaml
  1. Grafana should be available in https://foo.westeurope.cloudapp.azure.com/grafana/ Jaeger https://foo.westeurope.cloudapp.azure.com:16686

Known issues

Rate limits for Let's encrypt

The current setup uses production let's encrypt which limits the amounts of time a certificate can be issued to a certain email, IP or domain name

Jaeger routing

Jaeger doesn't work through https://domain/jaeger/
Research query.base-path to configure it

Parameterize domain name and email

Changing mentions of "foo.westeurope.cloudapp.azure.com" is cumbersome and parametrizing these would be nice

Setting DNS manually

Using Azure Portal to set "foo" for Ambassador IP domain name is annoying. Research how to do this automatically.

@msrn msrn linked an issue May 5, 2021 that may be closed by this pull request
@hjhsalo
Copy link
Collaborator

hjhsalo commented May 9, 2021

I would like to see the following done with Terraform.

Head over to Azure Portal -> Resource Groups
Select your resource group MC_barkuksatrng-k8stest-...
Check each "kubernetes-aXXXXXXXXXXXXXX" Public IP until you find the one for ambassador
Select Configuration on the left menu
Write your unique DNS name label foo and Save

Create a Public IP address with something like following:
(adapted from https://stackoverflow.com/q/64740298)

resource "azurerm_public_ip" "ambassador-ingress" {
  name                = "ambassador-ingress-pip"
  location            = azurerm_kubernetes_cluster.aks.location
  resource_group_name = azurerm_kubernetes_cluster.aks.node_resource_group
  
  ## or allocation_method = "Dynamic" is sku is "Basic":
  ## https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip#sku
  sku                 = "Standard"
  allocation_method   = "Static" 
  
  domain_name_label   = var.dns_name_prefix
}

Push created IP-address to Ambassador's Helm chart config.
There is a service.loadBalancerIP in Ambassador Helm chart configuration which seems to be used to propagate loadBalancerIP to Ambassador's K8S Service definition.
(https://github.com/datawire/ambassador-chart/tree/c540b0d9e91f7def8a7d9b99217cb62cfe3014fb#configuration)

Note that Azure specific service.beta.kubernetes.io/azure-load-balancer-resource-group might be needed for Ambassador's K8S Service. (https://docs.microsoft.com/en-us/azure/aks/static-ip#create-a-service-using-the-static-ip-address)

Azure specific service.beta.kubernetes.io/azure-dns-label-name annotation might be all that is needed to create a DNS entry for Ambassador's K8S Service. I.e. no public ip needs to be created with Terraform. (https://docs.microsoft.com/en-us/azure/aks/static-ip#apply-a-dns-label-to-the-service)

Annotations for Ambassador's K8S Service seem to be defined by 'service.annotations' key of Ambassador's Helm chart config.
(Not sure what should go inside the string for multiple annotations) https://github.com/datawire/ambassador-chart/blob/c540b0d9e91f7def8a7d9b99217cb62cfe3014fb/templates/service.yaml#L31-L35)

Related documentation and information available here:

@hjhsalo
Copy link
Collaborator

hjhsalo commented May 9, 2021

Since DNS name, smaddis.westeurope.cloudapp.azure.com hardcoded in the PR, would need to be parametrized (e.g. to support multiple, workspaced named deployments), tls.yaml could

@hjhsalo
Copy link
Collaborator

hjhsalo commented May 9, 2021

DNS name parametrization should also be done for various Helm values.yaml files.
Terraform Helm provider mentions merging of values and set keys for helm_release resources: https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#set

I'm not sure if 'set' is the best/correct way to parameterize values.yaml or does it have some drawbacks.
One alternative is to use 'yamlencode' available in Terraform: hashicorp/terraform-provider-helm#669 (comment)

@msrn msrn changed the base branch from master to tls-branch June 1, 2021 10:54
@msrn msrn merged commit 9b9a47e into smaddis:tls-branch Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe-to-test PR's that are safe to test with the pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cert-manager to K8S for automatic TLS encrypted traffic
2 participants