Kubernetes provide cannot create namespace

Hi,

I’m trying to create a Kubernetes namespace, with the kubernetes provider, in combination with the kubernetes_namespace resource, but I keep getting the following error:

Error: the server could not find the requested resource (post namespaces)

Does anyone know what is causing this?

Many thanks,

John

You have use the kubernetes provider first with login credentials. here is the code example, which i am using and working perfectly fine.

provider “kubernetes” {

load_config_file = “false”
host = azurerm_kubernetes_cluster.resource-block-name.kube_config.0.host
username = azurerm_kubernetes_cluster.resource-block-name.kube_config.0.username
password = azurerm_kubernetes_cluster.resource-block-name.kube_config.0.password
client_certificate = “${base64decode(azurerm_kubernetes_cluster.resource-block-name.kube_config.0.client_certificate)}”

client_key = “${base64decode(azurerm_kubernetes_cluster.resource-block-name.kube_config.0.client_key)}”

cluster_ca_certificate = “${base64decode(azurerm_kubernetes_cluster.resource-block-name.kube_config.0.cluster_ca_certificate)}”
}

resource “kubernetes_namespace” “k8s-namespace” {
metadata {
labels = { mylabel = “Intikhab’s namespace” }
name = “namespace-name” }
}