1. 이슈

    kubeconfig 파일이 Windows 경로에 저장되고 있어서 Linux 환경에서 읽지 못하고 있음

  2. 해결

    Linux 환경에 kubeconfig 파일 생성

    mkdir -p ~/.kube
    az aks get-credentials --resource-group cheol-ollacare-rg --name aks-cluster --file ~/.kube/config
    

    kubeconfig 파일 권한 설정

    chmod 600 ~/.kube/config
    

    환경 변수 설정

    export KUBECONFIG=~/.kube/config
    

    kubectl 설정 확인

    kubectl config view
    

    클러스터 연결 테스트

    kubectl cluster-info
    

    노드 확인

    kubectl get nodes
    
  3. 코드 HISTORY

    cheol@BASTION-VM:/$ az account set --subscription 7927a549-7f89-4f9f-8805-0ba8af8da1e4
    
    cheol@BASTION-VM:/$ az aks get-credentials --resource-group cheol-ollacare-rg --name aks-cluster --overwrite-existing
    Merged "aks-cluster" as current context in C:\\Users\\cheol\\.kube\\config
    
    cheol@BASTION-VM:/$ kubectl get pod
    E0812 00:38:48.674057    6947 memcache.go:265] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
    E0812 00:38:48.675877    6947 memcache.go:265] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
    E0812 00:38:48.676550    6947 memcache.go:265] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
    E0812 00:38:48.678651    6947 memcache.go:265] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
    E0812 00:38:48.679140    6947 memcache.go:265] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
    The connection to the server localhost:8080 was refused - did you specify the right host or port?
    
    cheol@BASTION-VM:/$ mkdir -p ~/.kube
    
    cheol@BASTION-VM:/$ ls
    Docker  boot  etc   init     lib    lib64   lost+found  mnt  proc  run   snap  sys  usr
    bin     dev   home  kubectl  lib32  libx32  media       opt  root  sbin  srv   tmp  var
    
    cheol@BASTION-VM:/$ ls -a
    .   Docker  boot  etc   init     lib    lib64   lost+found  mnt  proc  run   snap  sys  usr
    ..  bin     dev   home  kubectl  lib32  libx32  media       opt  root  sbin  srv   tmp  var
    
    cheol@BASTION-VM:/$ az aks get-credentials --resource-group cheol-ollacare-rg --name aks-cluster --file ~/.kube/config
    Merged "aks-cluster" as current context in /home/cheol/.kube/config
    cheol@BASTION-VM:/$ chmod 600 ~/.kube/config
    cheol@BASTION-VM:/$ export KUBECONFIG=~/.kube/config
    cheol@BASTION-VM:/$ kubectl config view
    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority-data: DATA+OMITTED
        server: <https://aks-cluste-cheol-ollacare-r-7927a5-fghv1qhq.privatelink.koreacentral.azmk8s.io:443>
      name: aks-cluster
    contexts:
    - context:
        cluster: aks-cluster
        user: clusterUser_cheol-ollacare-rg_aks-cluster
      name: aks-cluster
    current-context: aks-cluster
    kind: Config
    preferences: {}
    users:
    - name: clusterUser_cheol-ollacare-rg_aks-cluster
      user:
        client-certificate-data: DATA+OMITTED
        client-key-data: DATA+OMITTED
        token: REDACTED
    
    cheol@BASTION-VM:/$ kubectl get nodes
    NAME                                STATUS   ROLES   AGE   VERSION
    aks-nodepool1-24238543-vmss000002   Ready    agent   21m   v1.28.10
    aks-nodepool1-24238543-vmss000003   Ready    agent   21m   v1.28.10
    cheol@BASTION-VM:/$