How to update/reset kubernetes cluster config

ascii-c 31 Reputation points
2020-06-23T07:23:24.013+00:00

I have deleted the first AKS setup I created as well as the resource group in Azure.
Then created a new one, Hyperledger-Fabric-on-Azure-Kubernetes-Service, which set to region US West.
The first one used region SouthAustralia.

After new AKS setup is done, I checked the pods and the context.

az_dev@Azure:~$ kubectl get current-context
Unable to connect to the server: dial tcp: lookup hlf01-hlf-aks-dns-xxxxxx.hcp.australiasoutheast.azmk8s.io on 168.63.129.16:53: no such host
az_dev@Azure:~$ 

Checking the the kube config, it still displays the old config.

az_dev@Azure:~$ kubectl config view
    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority-data: xxxxxxxxxxxxxxxxxxxxxxxxxxx==
        server: https://hlf02-hlf-aks-dns-xxxxxxx.hcp.australiasoutheast.azmk8s.io:443
      name: hlf02-HLF-AKS
    - cluster:
        certificate-authority-data: xxx==
        server: https://hlf01-hlf-aks-dns-xxxxxx.hcp.australiasoutheast.azmk8s.io:443
      name: hlf01-HLF-AKS
    contexts:
    - context:
        cluster: hlf02-HLF-AKS
        user: clusterUser_dev-hlf02_hlf02-HLF-AKS
      name: hlf02-HLF-AKS
    - context:
        cluster: hlf01-HLF-AKS
        user: clusterUser_dev-hlf01_hlf01-HLF-AKS
      name: hlf01-HLF-AKS
    current-context: hlf01-HLF-AKS
    kind: Config
    preferences: {}
    users:
    - name: clusterUser_dev-hlf02_hlf02-HLF-AKS
      user:
        client-certificate-data: xxxxxxxxxxxxxxxxxxxxxxxx==
        client-key-data: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        token: xxxxxxxxxxxxxxxxxxxx
    - name: clusterUser_dev-hlf01_hlf01-HLF-AKS
      user:
        client-certificate-data: xxxxxxxxxxxxxxxxx==
        client-key-data: xxxxxxxxxxxxxxxxxxxx==
        token: xxxxxxxxxxxxxxxxxx

How do I update the kube config?
If I update it manually from $HOME/.kube/config, how do I get the new values from the new cluster (token, client cert)?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,987 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,664 questions
0 comments No comments
{count} votes

Accepted answer
  1. vipullag-MSFT 25,866 Reputation points
    2020-06-23T08:26:52.113+00:00

    @ascii-c

    kubectl is using kubeconfig which is no longer valid.

    You can get updated kubeconfig file via "az aks get-credentials" command, Link for reference.

    You can also remove previously configured kubeconfig context and config from kubectl command line, check this link for more info.

    Hope this helps.

    Thanks.

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics.


1 additional answer

Sort by: Most helpful
  1. ascii-c 31 Reputation points
    2020-06-24T00:16:12.3+00:00

    @vipullag-MSFT This one detects the newly the westus cluster.

     az_dev@Azure:~$ az aks list --resource-group dev-hlf1 --subscription xxxx-xxx-xxxx-xx-xxxxxxxxxxx
     [
     {
     "aadProfile": null,
     "addonProfiles": {
     "httpApplicationRouting": {
     "config": {
     "HTTPApplicationRoutingZoneName": "xxxxxxxxxx.westus.aksapp.io"
     },
     "enabled": true,
     "identity": null
     },
     "omsagent": {
     "config": {
     "logAnalyticsWorkspaceResourceID": "/subscriptions/xxxx-xxxx-xxx-xxxx-xxxxx/resourceGroups/dev-hlf1/providers/microsoft.operationalinsights/workspaces/hlf12020-06-12T02-18-57"
     },
     "enabled": true,
     "identity": null
     }
     },
     "agentPoolProfiles": [
     {
     "availabilityZones": null,
     "count": 2,
     "enableAutoScaling": null,
     "enableNodePublicIp": null,
     "maxCount": null,
     "maxPods": 30,
     "minCount": null,
     "mode": "User",
     "name": "agentpool",
     "nodeLabels": null,
     "nodeTaints": null,
     "orchestratorVersion": "1.15.11",
     "osDiskSizeGb": 128,
     "osType": "Linux",
     "provisioningState": "Succeeded",
     "scaleSetEvictionPolicy": null,
     "scaleSetPriority": null,
     "spotMaxPrice": null,
     "tags": null,
     "type": "AvailabilitySet",
     "vmSize": "Standard_B2s"
     }
     ],
     "apiServerAccessProfile": null,
     "autoScalerProfile": null,
     "diskEncryptionSetId": null,
     "dnsPrefix": "dev-hlf1-HLF-AKS-dns",
     "enablePodSecurityPolicy": null,
     "enableRbac": true,
     "fqdn": "dev-hlf1-hlf-aks-dns-xxxx.hcp.westus.azmk8s.io",
     "id": "/subscriptions/xxxx-xxxx-xxxx-xxxx-xxxxxxx/resourcegroups/dev-hlf1/providers/Microsoft.ContainerService/managedClusters/dev-hlf1-HLF-AKS",
     "identity": null,
     "identityProfile": null,
     "kubernetesVersion": "1.15.11",
     "linuxProfile": null,
     "location": "westus",
     "maxAgentPools": 1,
     "name": "dev-hlf1-HLF-AKS",
     "networkProfile": {
     "dnsServiceIp": "10.0.0.10",
     "dockerBridgeCidr": "172.17.0.1/16",
     "loadBalancerProfile": null,
     "loadBalancerSku": "Basic",
     "networkMode": null,
     "networkPlugin": "azure",
     "networkPolicy": null,
     "outboundType": "loadBalancer",
     "podCidr": null,
     "serviceCidr": "10.0.0.0/16"
     },
     "nodeResourceGroup": "MC_dev-hlf1_dev-hlf1-HLF-AKS_westus",
     "privateFqdn": null,
     "provisioningState": "Succeeded",
     "resourceGroup": "dev-hlf1",
     "servicePrincipalProfile": {
     "clientId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx"
     },
     "sku": {
     "name": "Basic",
     "tier": "Free"
     },
     "type": "Microsoft.ContainerService/ManagedClusters",
     "windowsProfile": null
     }