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

[BUG] Can't delete a Kubernetes cluster #176

Open
nlamirault opened this issue Apr 18, 2023 · 7 comments
Open

[BUG] Can't delete a Kubernetes cluster #176

nlamirault opened this issue Apr 18, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@nlamirault
Copy link

nlamirault commented Apr 18, 2023

Description

I create a Kubernetes cluster using Terraform Civo provider v1.0.31:

https://dashboard.civo.com/kubernetes/44705df8-5e98-4e24-a362-7ac43f1696da

When i try a terraform destroy i've got this error :

Plan: 0 to add, 0 to change, 3 to destroy.
╷
│ Warning: Deprecated Resource
│ 
│   with module.kubernetes.civo_firewall_rule.this,
│   on .terraform/modules/kubernetes/firewall.tf line 21, in resource "civo_firewall_rule" "this":
│   21: resource "civo_firewall_rule" "this" {
│ 
│ This resource is deprecated, please use the `civo_firewall` resource
│ instead
╵
╷
│ Error: [INFO] error getting kubernetes cluster: 44705df8-5e98-4e24-a362-7ac43f[169](https://github.com/portefaix/portefaix-infrastructure/actions/runs/4734909528/jobs/8404459496#step:6:169)6da
│ 
│ 
╵
Operation failed: failed running terraform apply (exit 1)

Deletion works fine using the UI.

Screenshots

Kubernetes-Civo-com

Additional information

No response

@tusharrverma
Copy link

tusharrverma commented Apr 23, 2023

Hi @nlamirault
I believe if you use the resource "civo_firewall" instead of "civo_firewall_rule", the error shouldn't appear and cluster shall be deleted successfully.

As I see the code, function "civo_firewall_rule" is mentioned as deprecated but not removed from the code yet, maybe team wants users to get to know (via error) that resource name is now changed (to "civo_firewall").

And it's working OK via UI because there's no issue as such in backend. Hope it helps!

@nlamirault
Copy link
Author

i change the Terraform code using firewall_rule and i've got this error:

/home/runner/work/_temp/9bf719d5-dc1f-41ce-b968-b1dcd7ea696a/terraform-bin destroy -auto-approve
Running apply in the remote backend. Output will stream here. Pressing Ctrl-C
will cancel the remote apply if it's still pending. If the apply started it
will stop streaming the logs, but will not stop the apply running remotely.

Preparing the remote apply...

The remote workspace is configured to work with configuration at
terraform/civo/kubernetes/dev relative to the target repository.

Terraform will upload the contents of the following directory,
excluding files or directories as defined by a .terraformignore file
at /home/runner/work/portefaix-infrastructure/portefaix-infrastructure/.terraformignore (if it is present),
in order to capture the filesystem context the remote workspace expects:
    /home/runner/work/portefaix-infrastructure/portefaix-infrastructure

To view this run in a browser, visit:
https://app.terraform.io/app/portefaix/portefaix-civo-dev-kubernetes/runs/run-ehhvVot3AAtZAHMo

Waiting for the plan to start...

Terraform v1.4.5
on linux_amd64
Initializing plugins and modules...
module.kubernetes.module.kubernetes.data.civo_network.this: Reading...
module.kubernetes.module.kubernetes.data.civo_network.this: Read complete after 3s [id=58e2b60e-d8e4-41ab-9a9a-d[7](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:8)a520[8](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:9)2[9](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:10)4bc]
module.kubernetes.module.kubernetes.civo_firewall.this: Refreshing state... [id=39bfc909-57c8-4843-bc52-3e566a597f92]
module.kubernetes.module.kubernetes.civo_kubernetes_cluster.this: Refreshing state... [id=d4905778-d055-4281-a4be-081687540381]
module.kubernetes.module.kubernetes.civo_kubernetes_node_pool.this[0]: Refreshing state... [id=addons]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # module.kubernetes.module.kubernetes.civo_firewall.this will be destroyed
  - resource "civo_firewall" "this" {
      - create_default_rules = false -> null
      - id                   = "39bfc909-57c8-4843-bc52-3e566a597f92" -> null
      - name                 = "portefaix-dev-civo" -> null
      - network_id           = "58e2b60e-d8e4-41ab-9a9a-d7a5208294bc" -> null
      - region               = "LON1" -> null

      - egress_rule {
          - action     = "allow" -> null
          - cidr       = [
              - "0.0.0.0/0",
            ] -> null
          - id         = "06c773e8-ce96-494b-8a5d-00b75a682e52" -> null
          - label      = "all" -> null
          - port_range = "1-65535" -> null
          - protocol   = "tcp" -> null
        }

      - ingress_rule {
          - action     = "allow" -> null
          - cidr       = [
              - "91.163.213.235/32",
            ] -> null
          - id         = "0c544219-a088-43[10](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:11)-ab78-f43245262ef8" -> null
          - label      = "ssh" -> null
          - port_range = "22" -> null
          - protocol   = "tcp" -> null
        }
      - ingress_rule {
          - action     = "allow" -> null
          - cidr       = [
              - "91.163.2[13](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:14).235/32",
            ] -> null
          - id         = "24b4a32d-c04a-4896-b873-cdae87e01db4" -> null
          - label      = "k8s" -> null
          - port_range = "6443" -> null
          - protocol   = "tcp" -> null
        }
    }

  # module.kubernetes.module.kubernetes.civo_kubernetes_cluster.this will be destroyed
  - resource "civo_kubernetes_cluster" "this" {
      - api_endpoint           = "https://74.220.18.252:6443" -> null
      - cluster_type           = "k3s" -> null
      - cni                    = "cilium" -> null
      - created_at             = "2023-05-18 [15](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:16):51:01 +0000 UTC" -> null
      - dns_entry              = "d4905778-d055-4281-a4be-08[16](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:17)87540381.k8s.civo.com" -> null
      - firewall_id            = "39bfc909-57c8-4843-bc52-3e566a597f92" -> null
      - id                     = "d4905778-d055-4281-a4be-081687540381" -> null
      - installed_applications = [] -> null
      - kubeconfig             = (sensitive value) -> null
      - kubernetes_version     = "1.23.6-k3s1" -> null
      - master_ip              = "74.220.[18](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:19).252" -> null
      - name                   = "portefaix-dev-civo" -> null
      - network_id             = "58e2b60e-d8e4-41ab-9a9a-d7a5[20](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:21)8294bc" -> null
      - num_target_nodes       = 1 -> null
      - ready                  = true -> null
      - region                 = "LON1" -> null
      - status                 = "ACTIVE" -> null
      - target_nodes_size      = "g3.k3s.small" -> null

      - pools {
          - instance_names = [
              - "k3s-portefaix-dev-civo-691a-dd82d8-node-pool-4e40-laj7i",
            ] -> null
          - label          = "addons" -> null
          - node_count     = 1 -> null
          - size           = "g3.k3s.small" -> null
        }
    }

  # module.kubernetes.module.kubernetes.civo_kubernetes_node_pool.this[0] will be destroyed
  - resource "civo_kubernetes_node_pool" "this" {
      - cluster_id     = "d4905778-d055-4[28](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:29)1-a4be-081687540[38](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:39)1" -> null
      - id             = "addons" -> null
      - instance_names = [
          - "k3s-portefaix-dev-civo-691a-dd82d8-node-pool-4e40-laj7i",
        ] -> null
      - label          = "addons" -> null
      - node_count     = 1 -> null
      - region         = "LON1" -> null
      - size           = "g3.k3s.small" -> null
    }

Plan: 0 to add, 0 to change, 3 to destroy.


╷
│ Error: [INFO] error getting kubernetes cluster: d4905778-d055-4281-a4be-0816875[40](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:41)3[81](https://github.com/portefaix/portefaix-infrastructure/actions/runs/5015764944/jobs/8991757561#step:6:82)
│ 
│ 
╵
Operation failed: failed running terraform apply (exit 1)
Error: Terraform exited with code 1.
Error: Process completed with exit code 1.

@alejandrojnm
Copy link
Member

HI @nlamirault the cluster exists in your account? in what region is ?

@nlamirault
Copy link
Author

yes @alejandrojnm . I execute a terraform apply to create the Kubernetes cluster, network, and firewall rules. Then a terraform destroy on the same code.
Region is LON1

@alejandrojnm
Copy link
Member

The cluster is still there??

@nlamirault
Copy link
Author

no i deleted the cluster using the UI.

@alejandrojnm
Copy link
Member

@nlamirault is error is gone ??, is for close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants