Kubernetes 问题

Kubernetes Issue

我有微服务(在Node.js) 我正在为它创建一个 docker 图像并将其推送到我的本地注册表 运行 localhost:5001

在使用 helm 部署此微服务时

helm upgrade --install --wait --set env=dev --set image.tag=localhost:5001/user-service userservice-api ./build/helm --namespace dev --create-namespace --kube-context http://localhost:5001

我明白了

Error: Kubernetes cluster unreachable: context "http://localhost:5001" does not exist

我如何找到 issue/resolve 它?

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "chart.fullname" . }}
  labels:
    {{- include "chart.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "chart.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "chart.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}    
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 4006
              protocol: TCP
          env:
            - name: ENV
              value: "{{ .Values.env }}"
          readinessProbe:
            httpGet:
              path: /health
              port: 4006
            initialDelaySeconds: 15
            periodSeconds: 10

          livenessProbe:
            httpGet:
              path: /health
              port: 4006
            initialDelaySeconds: 15
            periodSeconds: 10

values.yaml

replicaCount: 1

image:
  repository: localhost:5001/user-service

附加信息

有人可以帮我解决这个问题吗?

在 Dockerfile 中

RUN npm ci 

必须改为

在 Dockerfile 中

RUN npm ci --force

为我解决了问题。