• Rename resources from the terraform state

    3 min read

    terraform refactor state move resource Infrastructure as Code

    When handling Infrastructure as Code (IaC) with terraform, refactoring the code might cause terraform to try to delete the existing resources an recreate them using a different name:

      # module.jenkins.module.worker.module.kms-parameter-store.aws_iam_policy.kms_read_policy will be destroyed
      # module.jenkins.module.worker.module.kms-parameter-store.aws_iam_policy.ssm_read_policy will be destroyed
      # module.jenkins.module.worker.module.kms-parameter-store.aws_iam_role_policy_attachment.kms_read_policy_attachment will be destroyed
      # module.jenkins.module.worker.module.kms-parameter-store.aws_iam_role_policy_attachment.ssm_role_policy_attachment will be destroyed
      # module.jenkins.module.worker.module.kms-parameter-store.aws_kms_alias.kms_key_alias will be destroyed
      # module.jenkins.module.worker.module.kms-parameter-store.aws_kms_key.kms_key will be destroyed
    
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_iam_policy.kms_read_policy will be created
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_iam_policy.ssm_read_policy will be created
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_iam_role_policy_attachment.kms_read_policy_attachment will be created
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_iam_role_policy_attachment.ssm_role_policy_attachment will be created
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_kms_alias.kms_key_alias will be created
      # module.jenkins.module.worker[0].module.kms-parameter-store.aws_kms_key.kms_key will be created
    

    While in some cases it's just fine to destroy the resources and recreate them back, in other cases it can cause a undesired service interruption just for deleting all the resources and recreate them back exactly with the same settings using slightly different name on the terraform state.

    We can avoid it by renaming the resources in the terraform state to the name terraform is expecting

    23/04/2021

    Read more...
  • Create a helm chart template

    2 min read

    helm template chart

    To get started creating a helm chart on our own there are some common structure that we can reuse from chart to chart: We can let helm create the basic structure for us

    22/04/2021

    Read more...
  • How to release a helm chart on our own repo

    2 min read

    helm repo release package

    To be able to create a release of a helm chart we will need to first, create the package and then generate / update the index.yaml for being able to serve it as a repo using any webserver of our choice

    21/04/2021

    Read more...
  • Kubernetes Ingress: Required value: pathType must be specified

    1 min read

    Ingress kubernetes pathType pathType must be specified

    While upgrading Ingress objects to networking.k8s.io/v1 you'll find out, among other changes that now the pathType is a required option:

    spec.rules[0].http.paths[0].pathType: Required value: pathType must be specified, spec.rules[0].http.paths[1].pathType: Required value: pathType must be specified
    

    20/04/2021

    Read more...
  • Troubleshoot Kubernetes service not being resolved

    2 min read

    unresolving kubernetes service DNS

    When you create a Kubernetes Service, pods from within the same namespace should be able to resolve it's IP by name. For example, if we create a service named ampa-votacions; any pod from the same namespace should be able to resolve it's IP. But sometimes it can't be resolved:

    $ kubectl exec -it ampa-install-ws7cw -- sh
    / $ nslookup ampa-votacions
    Server:   172.20.0.10
    Address:  172.20.0.10:53
    
    ** server can't find ampa-votacions.us-west-2.compute.internal: NXDOMAIN
    
    ** server can't find ampa-votacions.ampa.svc.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.svc.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.ampa.svc.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.svc.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.cluster.local: NXDOMAIN
    
    ** server can't find ampa-votacions.us-west-2.compute.internal: NXDOMAIN
    

    19/04/2021

    Read more...

More recent...

Older content...