helm icon indicating copy to clipboard operation
helm copied to clipboard

helm install does not show validation errors that kubectl apply does

Open janitha09 opened this issue 7 years ago • 2 comments

I nested the imagePullSecrets at the wrong level.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "tideworks-activemq.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "tideworks-activemq.name" . }}
    helm.sh/chart: {{ include "tideworks-activemq.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "tideworks-activemq.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "tideworks-activemq.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          imagePullSecrets:
            - name: {{ .Values.image.pullSecret }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
    {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
    {{- end }}```

ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ helm lint
==> Linting .
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, no failures
ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ helm install --debug --name tideworks-amq .
[debug] Created tunnel using local port: '38027'

[debug] SERVER: "127.0.0.1:38027"

[debug] Original chart version: ""
[debug] CHART PATH: /home/ubuntu/WIP/tideworks-activemq

NAME:   tideworks-amq
REVISION: 1
RELEASED: Tue Apr 23 18:22:28 2019
CHART: tideworks-activemq-0.1.0
USER-SUPPLIED VALUES:
{}

COMPUTED VALUES:
affinity: {}
fullnameOverride: ""
image:
  pullPolicy: IfNotPresent
  pullSecret: regcred
  repository: 369551733582.dkr.ecr.us-east-2.amazonaws.com/trafficcontrolbeacon
  tag: activemq
ingress:
  annotations: {}
  enabled: false
  hosts:
  - host: chart-example.local
    paths: []
  tls: []
nameOverride: ""
nodeSelector: {}
replicaCount: 1
resources: {}
service:
  port: 80
  type: ClusterIP
tolerations: []

HOOKS:
---
# tideworks-amq-tideworks-activemq-test-connection
apiVersion: v1
kind: Pod
metadata:
  name: "tideworks-amq-tideworks-activemq-test-connection"
  labels:
    app.kubernetes.io/name: tideworks-activemq
    helm.sh/chart: tideworks-activemq-0.1.0
    app.kubernetes.io/instance: tideworks-amq
    app.kubernetes.io/managed-by: Tiller
  annotations:
    "helm.sh/hook": test-success
spec:
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args:  ['tideworks-amq-tideworks-activemq:80']
  restartPolicy: Never
MANIFEST:

---
# Source: tideworks-activemq/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: tideworks-amq-tideworks-activemq
  labels:
    app.kubernetes.io/name: tideworks-activemq
    helm.sh/chart: tideworks-activemq-0.1.0
    app.kubernetes.io/instance: tideworks-amq
    app.kubernetes.io/managed-by: Tiller
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: tideworks-activemq
    app.kubernetes.io/instance: tideworks-amq
---
# Source: tideworks-activemq/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tideworks-amq-tideworks-activemq
  labels:
    app.kubernetes.io/name: tideworks-activemq
    helm.sh/chart: tideworks-activemq-0.1.0
    app.kubernetes.io/instance: tideworks-amq
    app.kubernetes.io/managed-by: Tiller
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: tideworks-activemq
      app.kubernetes.io/instance: tideworks-amq
  template:
    metadata:
      labels:
        app.kubernetes.io/name: tideworks-activemq
        app.kubernetes.io/instance: tideworks-amq
    spec:
      containers:
        - name: tideworks-activemq
          image: "xxxxxxx.dkr.ecr.us-east-2.amazonaws.com/trafficcontrolbeacon:activemq"
          imagePullPolicy: IfNotPresent
          imagePullSecrets:
            - name: regcred
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {}
LAST DEPLOYED: Tue Apr 23 18:22:28 2019
NAMESPACE: kafka
STATUS: DEPLOYED

RESOURCES:
==> v1/Deployment
NAME                              READY  UP-TO-DATE  AVAILABLE  AGE
tideworks-amq-tideworks-activemq  0/1    1           0          0s

==> v1/Pod(related)
NAME                                               READY  STATUS             RESTARTS  AGE
tideworks-amq-tideworks-activemq-84dd678496-9hpvp  0/1    ContainerCreating  0         0s

==> v1/Service
NAME                              TYPE       CLUSTER-IP      EXTERNAL-IP  PORT(S)  AGE
tideworks-amq-tideworks-activemq  ClusterIP  10.109.150.188  <none>       80/TCP   0s


NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace kafka -l "app.kubernetes.io/name=tideworks-activemq,app.kubernetes.io/instance=tideworks-amq" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:80

the pod fails because the image cannot be pulled from the private registry

ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ kubectl logs tideworks-amq-tideworks-activemq-84dd678496-9hpvp
Error from server (BadRequest): container "tideworks-activemq" in pod "tideworks-amq-tideworks-activemq-84dd678496-9hpvp" is waiting to start: trying and failing to pull image

From the debg output above taking the deployment section out and applying it like so

ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ kubectl apply -f deployments
error: error validating "deployments": error validating data: ValidationError(Deployment.spec.template.spec.containers[0]): unknown field "imagePullSecrets" in io.k8s.api.core.v1.Container; if you choose to ignore these errors, turn validation off with --validate=false

Output of helm version:

ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ helm version
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}

Output of kubectl version:

ubuntu@ip-172-31-31-192:~/WIP/tideworks-activemq$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:02:58Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): EC2

janitha09 avatar Apr 23 '19 18:04 janitha09

This appears to be a duplicate of https://github.com/helm/helm/issues/2575. I'm going to go ahead and close this as a duplicate feature request, but please let me know if this is not the case and we can look into it. Thanks!

bacongobbler avatar Apr 23 '19 19:04 bacongobbler

You can try this before apply helm helm template x . --debug | kubectl apply --dry-run -f -

jrsalgado avatar May 15 '20 17:05 jrsalgado