Upgrade Kubernetes Cluster using Terraform's provisioner

jagatjyoti

Scenario:

I have a situation where I don't have the liberty to use any market available Kubernetes upgrade tool like KOps or KubeSpray. So, I'm compelled to use Terraform to provision the instances and kubernetes is installed as part of bootstrapping using provisioners. Now, the catchy part is, my K8s cluster is running on version 1.11.6 and I want to upgrade it to 1.12.3.

What I did:

In the terraform scripts, I doubled node count and updated the K8s version. Then did the Terraform deployment. I was successful in upgrading the new nodes (the nodes formed after doubling count). Post which I terminated the instances running old version on K8s. Now I only have the new nodes with new version of K8s running on them. Then ran terraform refresh so as to sync the statefile with real resources which exist remotely on AWS.

Problem

To verify the statefile and remote are in sync, I ran terraform plan which shows some resources to be created. Basically, the plan shows it's going to create the new nodes again. Unable to understand why so !!

Please can someone clarify what's going wrong here ? Thanks in advance.

Update:

My K8s version map

type = "map"
default = {
        kubernetes = "1.11.5"
        etcd = "3.3.1"
        dockerCE = "18.06.1.ce-3.el7"
        cfssl = "1.2"
        kube-dns = "1.14.10"
        core-dns = "1.2.0"
        helm = "2.9.1"
        calico-node = "3.0.6"
        calico-cni = "2.0.5"
        calico-kube-controller = "2.0.4"
        nginx-ingress-controller = "0.19.0"
}

My node count (for master below, but same for all nodes like etcd, ca, worker etc)

variable "MASTER_COUNT" {
        type = "map"
        default = {
                #bastion
                dev = "1"
                prod = "3"
        }

Terraform plan still shows below resources to be created. Basically it tries to recreate the nodes with older version of K8s, which shouldn't be as I have already ran terraform refresh which should sync my local and remote.

Terraform will perform the following actions:

  + module.master.aws_instance.ec2-master[0]
      id:                                                <computed>
      ami:                                               "ami-######"
      arn:                                               <computed>
      associate_public_ip_address:                       <computed>
      availability_zone:                                 <computed>
      cpu_core_count:                                    <computed>
      cpu_threads_per_core:                              <computed>
      ebs_block_device.#:                                "2"

  + module.master.aws_instance.ec2-master[1]
      id:                                                <computed>
      ami:                                               "ami-#######"
      arn:                                               <computed>
      associate_public_ip_address:                       <computed>
      availability_zone:                                 <computed>
      cpu_core_count:                                    <computed>
      cpu_threads_per_core:                              <computed>
      ebs_block_device.#:                                "2"

  + module.master.aws_instance.ec2-master[2]
      id:                                                <computed>
      ami:                                               "ami-######"
      arn:                                               <computed>
      associate_public_ip_address:                       <computed>
      availability_zone:                                 <computed>
      cpu_core_count:                                    <computed>
      cpu_threads_per_core:                              <computed>
      ebs_block_device.#:                                "2"

  - module.master.aws_instance.ec2-master[3]

  - module.master.aws_instance.ec2-master[4]

  - module.master.aws_instance.ec2-master[5]

# some other re-creations like Auto scaling group, Load balancer changes etc

Plan: 10 to add, 1 to change, 16 to destroy.
jagatjyoti

Finally, I was able to resolve this which means a K8s minor upgrade is successful. Below steps were followed during the course:

  • Deploy a K8s cluster running version 1.11.2
  • Double the node count, change version to 1.11.5 and re-deploy
  • New nodes get created with updated version
  • Remove nodes running old version i.e. 1.11.2
  • Run terraform refresh so as to sync statefile with real world running Infrastructure
  • Change the node count to 3 or half it.
  • Run terraform plan and verify (multiple runs of refresh might be needed)
  • Run terraform apply to apply changes.
  • Statefile should be in sync with remote
  • Run terraform plan which shouldn’t show any resources to be created

I will be trying a major version upgrade shortly and post the results here.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to deploy to a (local) Kubernetes cluster using Jenkins

分類Dev

Reset Kubernetes cluster

分類Dev

Terraform、aws_eip、provisioner、local-exec、inconsistent ip addr

分類Dev

Kubernetes equivalent of Terraform modules and variables

分類Dev

Kubernetes - How to access nginx load balancing from outside the cluster using a NodePort service

分類Dev

I want to ping (icmp) monitor the worker nodes that make up the kubernetes cluster without using the internal IP of the node

分類Dev

Kubernetes Cluster Context with Multiple Namespaces

分類Dev

How to create a user in a Kubernetes cluster?

分類Dev

HPA + Cluster Autoscaler + OPA within Federated Kubernetes cluster on GKE

分類Dev

How to use kubeadm to create kubernetes cluster?

分類Dev

Pip installing a package inside of a Kubernetes cluster

分類Dev

Kubernetes cluster autoscaler does not seem to work on GKE?

分類Dev

how to configure already running cluster in kubernetes

分類Dev

What is the recommended architecture for scheduled jobs in Kubernetes cluster?

分類Dev

Kubernetes on single Windows Server Core node cluster

分類Dev

How to remove GPU in Google Kubernetes cluster (GKE)

分類Dev

Kubernetes cluster does not run after reboot

分類Dev

Setting Up Prometheus with Python in Kubernetes Cluster

分類Dev

How to find available resources in a Kubernetes Cluster level?

分類Dev

Schedule Cluster resizing on Google Kubernetes Engine

分類Dev

terraformazurerm_kubernetes_clusterノード

分類Dev

Terraform - How to Create a GKE Cluster and Install Helm Charts?

分類Dev

Unable to add capacity provider to AWS ECS cluster with terraform

分類Dev

Kubernetes hostpath-provisionerマウントパスを変更するにはどうすればよいですか?

分類Dev

Terraform using wrong version of provider

分類Dev

how to upgrade kubernetes from v1.10.0 to v1.10.11

分類Dev

Using Kubernetes' hooks

分類Dev

Configure kubectl command to access remote kubernetes cluster on azure

分類Dev

Configure kubectl command to access remote kubernetes cluster on azure

Related 関連記事

  1. 1

    How to deploy to a (local) Kubernetes cluster using Jenkins

  2. 2

    Reset Kubernetes cluster

  3. 3

    Terraform、aws_eip、provisioner、local-exec、inconsistent ip addr

  4. 4

    Kubernetes equivalent of Terraform modules and variables

  5. 5

    Kubernetes - How to access nginx load balancing from outside the cluster using a NodePort service

  6. 6

    I want to ping (icmp) monitor the worker nodes that make up the kubernetes cluster without using the internal IP of the node

  7. 7

    Kubernetes Cluster Context with Multiple Namespaces

  8. 8

    How to create a user in a Kubernetes cluster?

  9. 9

    HPA + Cluster Autoscaler + OPA within Federated Kubernetes cluster on GKE

  10. 10

    How to use kubeadm to create kubernetes cluster?

  11. 11

    Pip installing a package inside of a Kubernetes cluster

  12. 12

    Kubernetes cluster autoscaler does not seem to work on GKE?

  13. 13

    how to configure already running cluster in kubernetes

  14. 14

    What is the recommended architecture for scheduled jobs in Kubernetes cluster?

  15. 15

    Kubernetes on single Windows Server Core node cluster

  16. 16

    How to remove GPU in Google Kubernetes cluster (GKE)

  17. 17

    Kubernetes cluster does not run after reboot

  18. 18

    Setting Up Prometheus with Python in Kubernetes Cluster

  19. 19

    How to find available resources in a Kubernetes Cluster level?

  20. 20

    Schedule Cluster resizing on Google Kubernetes Engine

  21. 21

    terraformazurerm_kubernetes_clusterノード

  22. 22

    Terraform - How to Create a GKE Cluster and Install Helm Charts?

  23. 23

    Unable to add capacity provider to AWS ECS cluster with terraform

  24. 24

    Kubernetes hostpath-provisionerマウントパスを変更するにはどうすればよいですか?

  25. 25

    Terraform using wrong version of provider

  26. 26

    how to upgrade kubernetes from v1.10.0 to v1.10.11

  27. 27

    Using Kubernetes' hooks

  28. 28

    Configure kubectl command to access remote kubernetes cluster on azure

  29. 29

    Configure kubectl command to access remote kubernetes cluster on azure

ホットタグ

アーカイブ