kubernetes GitLab Runner中K3S的部署问题:“服务器找不到请求的资源”

c6ubokkw  于 12个月前  发布在  Kubernetes
关注(0)|答案(1)|浏览(87)

我在尝试从GitLab Runner在K3 S集群上部署Kubernetes资源时遇到了一个问题。错误消息表明服务器无法找到请求的资源。以下是相关详细信息:

  • GitLab CI/CD配置为部署Kubernetes资源。
  • 该集群是K3 S集群。
  • 使用kubectl apply命令,在API服务器请求期间发生错误。
  • 我可以使用kubectl get po -n kube-system成功地从集群中检索信息。
  • GitLab Runner具有必要的权限,因为它可以从集群中获取pod。

下面是我的.gitlab-ci.yaml文件的相关部分:

deploy:
  stage: deploy
  image:
    name: harbor.localdomain.ma/devops/lachlanevenson/k8s-kubectl:v1.9.2
    entrypoint: []
  extends:
    - .tag-small
  script:
    - mkdir $HOME/.kube
    - "echo $KUBECONF_DEFAULT | base64 -d > $HOME/.kube/config"
    - kubectl version --insecure-skip-tls-verify
    - kubectl get po -n kube-system 
    - pwd 
    - ls -lrth kubernetes
    - echo $CI_PROJECT_URL
    - cat /builds/BS-ocps/deployments/kubernetes/deployment.yaml > test.yaml
    - kubectl apply -f test.yaml -n bs -v=8 --insecure-skip-tls-verify
    - kubectl apply -f /builds/BS-ocps/deployments/kubernetes/service.yaml -n bs -v=8 --insecure-skip-tls-verify
    - kubectl get po -n bs

字符串
我得到的错误:

I1227 14:18:35.820599      57 loader.go:357] Config loaded from file /root/.kube/config
I1227 14:18:35.873465      57 round_trippers.go:414] GET https://CLUSTER_IP:6443/swagger-2.0.0.pb-v1
I1227 14:18:35.873550      57 round_trippers.go:421] Request Headers:
I1227 14:18:35.873567      57 round_trippers.go:424]     Accept: application/json, */*
I1227 14:18:35.873578      57 round_trippers.go:424]     User-Agent: kubectl/v1.9.2 (linux/amd64) kubernetes/5fa2db2
I1227 14:18:35.906258      57 round_trippers.go:439] Response Status: 404 Not Found in 32 milliseconds
I1227 14:18:35.906318      57 round_trippers.go:442] Response Headers:
I1227 14:18:35.906331      57 round_trippers.go:445]     X-Content-Type-Options: nosniff
I1227 14:18:35.906341      57 round_trippers.go:445]     X-Kubernetes-Pf-Flowschema-Uid: 3a3edf31-1f82-4b20-a18b-daed7dae0d7d
I1227 14:18:35.906393      57 round_trippers.go:445]     X-Kubernetes-Pf-Prioritylevel-Uid: a583e898-18a5-4e9d-9953-97a43f37688e
I1227 14:18:35.906403      57 round_trippers.go:445]     Content-Length: 19
I1227 14:18:35.906412      57 round_trippers.go:445]     Date: Wed, 27 Dec 2023 14:18:43 GMT
I1227 14:18:35.906422      57 round_trippers.go:445]     Audit-Id: 58cfcb04-f093-44b4-b3a5-b1c4d42f8816
I1227 14:18:35.906432      57 round_trippers.go:445]     Cache-Control: no-cache, private
I1227 14:18:35.906441      57 round_trippers.go:445]     Content-Type: text/plain; charset=utf-8
I1227 14:18:35.909213      57 request.go:873] Response Body: 404 page not found
I1227 14:18:35.912075      57 helpers.go:201] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "the server could not find the requested resource",
  "reason": "NotFound",
  "details": {
    "causes": [
      {
        "reason": "UnexpectedServerResponse",
        "message": "404 page not found"
      }
    ]
  },
  "code": 404
}]
F1227 14:18:35.912159      57 helpers.go:119] Error from server (NotFound): the server could not find the requested resource
Cleaning up file based variables
00:00
ERROR: Job failed: command terminated with exit code 255


任何见解或建议,解决这个问题将不胜感激.提前感谢!
我试着从我的机器上在集群上运行deployment.yaml,它工作正常,所以它没有任何问题。

yptwkmov

yptwkmov1#

我有这个错误,因为我在runner中使用过时的kubectl镜像,当更新到最新的镜像时,一切正常。

相关问题