티스토리 뷰

gitlab cicd 파이프라인에서 helm사용하여 deploy중 

Error: Kubernetes cluster unreachable: unable to parse the server version: invalid character '<' looking for beginning of value

에러가 났다.

 

local cmd에서 해당 helm명령어를 돌려보니 

Config not found: /etc/rancher/k3s/k3s.yaml

다음과 같은 config파일이 없다고 나온다.

 

다음과 같이 디렉토리를 생성하고  kubectl config view 내용의 k3s.yaml파일을 만든다.

mkdir /etc/rancher/k3s
vim /etc/rancher/k3s/k3s.yaml

apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

 

이러고 나서 다시 helm으로 배포를 하려고 하면

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /etc/rancher/k3s/k3s.yaml
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /etc/rancher/k3s/k3s.yaml

과 같은 경고 메세지가 나온다

 

이 permission들을 제거한다

chmod o-r /etc/rancher/k3s/k3s.yaml
chmod g-r /etc/rancher/k3s/k3s.yaml

잘 되는지 확인

helm version

아까의 경고메세지 사라짐

 

환경변수 KUBECONFIG셋팅

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

하면 에러해결

 

 

그래도 안되는 경우:: 방법1 yaml수정

 strace kubectl version

을 하면 

error: unable to parse the serve"..., 96error: unable to parse the server version: invalid character '<' looking for beginning of value

을 볼 수 있다. 이렇게 한번 에러가나서 모든 kubectl 명령이 막혀있는 상태가 되었다

 

kubectl -v 20 version

을 해도

error: unable to parse the server version: invalid character '<' looking for beginning of value

을 볼 수 있다

 

기본포트인 8080으로 접속하면

curl http://localhost:8080/api/

<html><body>You are being <a href="http://localhost:8080/users/sign_in">redirected</a>.</body></html>

이라고 나온다. 

 

 공식문서에 따르면

{
  "versions": [
    "v1"
  ],
  "serverAddressByClientCIDRs": [
    {
      "clientCIDR": "0.0.0.0/0",
      "serverAddress": "10.0.1.149:443"
    }
  ]
}

같이 나와야 한다는것을 알 수 있다.

 

minikube status에서 kubeconfig가 misconfigured되어 있어서 다음과 같은 명령어를 쳤더니

 minikube update-context

이제 kubectl은 다시 돌아간다.

 

디버깅

helm 파일의 deployment.yaml을 직접 디버깅해보았다

kubectl apply -f deployment.yaml

 

The Deployment "gitlab-cicd-homepage" is invalid: spec.template.spec.containers[0].name: Invalid value: "gitlabDeploy": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

다음과 같은 에러메세지가 나왔다.

 

 

이 에러는 yaml파일들을 디버깅해야한다.

 

그래도 안되는 경우:: 방법2 gitlab-CICD environment variable편집

[settings] - [ci/cd] - [variables]에서 추가하기

 

open /etc/rancher/k3s/k3s.yaml: permission denied

그런데 또 막상 환경변수를 추가하고 실행하면 다음과 같이 경로는 잡았는데 열지를 못할 수 있음

chown gitlab-runner /etc/rancher/k3s/k3s.yaml #소유자를 gitlab-runner로 한다
chmod 700 /etc/rancher/k3s/k3s.yaml #소유자만 rwx권한을 준다

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함