2

I am trying to build a sidecar image from skaffold and then push it onto my minikube cluster. My skaffold.yaml file looks like this :

   apiVersion: skaffold/v2beta28
    kind: Config
    metadata:
      name: sidecar
    build:
      artifacts:
      - image: amolgautam25/sidecar
        docker:
          dockerfile: Dockerfile
    deploy:
      kubectl:
        manifests:
        - pg-example.yaml

My pod deployment file (pg_example.yaml) looks like this :

    apiVersion: acid.zalan.do/v1
    kind: postgresql
    metadata: 
      name: vmw-test
    spec: 
      databases: 
        foo: zalando
      numberOfInstances: 1
      podAnnotations: 
        prometheus.io/port: "9187"
        prometheus.io/scrape: "true"
      postgresql: 
        parameters: 
          log_filename: postgresql.log
          log_rotation_age: "0"
          log_rotation_size: "0"
        version: "14"
      preparedDatabases: 
        bar: {}
      resources: 
        limits: 
          cpu: 500m
          memory: 500Mi
        requests: 
          cpu: "0"
          memory: "0"
      spiloFSGroup: 103
      spiloRunAsGroup: 103
      spiloRunAsUser: 101
      teamId: vmw
      users: 
        foo_user: []
        zalando: 
        - superuser
        - createdb
      volume: 
        size: 1Gi
      sidecars:
        - name: "postgres-exporter"
          image: quay.io/prometheuscommunity/postgres-exporter
          env:
          # The default "host    all             all                127.0.0.1/32       md5" rule in pg_hba.conf
          # allows us to connect over 127.0.0.1 without TLS as long as we have the password
          - name: DATA_SOURCE_URI
            value: "localhost:5432/postgres?sslmode=disable"
          - name: DATA_SOURCE_USER
            value: postgres
          - name: DATA_SOURCE_PASS
            valueFrom:
              secretKeyRef:
                key: password
                name: postgres.vmw-test.credentials.postgresql.acid.zalan.do
          ports:
          - name: exporter
            containerPort: 9187
            protocol: TCP
          resources:
            requests:
              cpu: 500m
              memory: 500Mi
            limits:
              cpu: 1000m
              memory: 1Gi
        - name: "metrics-sidecar"
          image: amolgautam25/sidecar

In the minikube images i can see the image built by skaffold

    <usename-hidden>$ minikube image ls -p my-profile
    docker.io/amolgautam25/sidecar:6b1af6a1fd25825dc63fd843f951e10c98bd9eb87d80cd8cf81da5641dc041e2

 
However, minikube refuses to use that image. Here is the error i get when i do describe pod:
  Normal   Pulling           7s               kubelet            Pulling image "amolgautam25/sidecar"
  Warning  Failed            6s               kubelet            Failed to pull image "amolgautam25/sidecar": rpc error: code = Unknown desc = Error response from daemon: pull access denied for amolgautam25/sidecar, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed            6s               kubelet            Error: ErrImagePull
  Normal   BackOff           3s (x2 over 5s)  kubelet            Back-off pulling image "amolgautam25/sidecar"
  Warning  Failed            3s (x2 over 5s)  kubelet            Error: ImagePullBackOff

But it seems that minikube already has that image. I have tried variations of docker.io/amolgautam25/sidecar etc but it does not work. Any help would be appreciated.

Edit:

On further investigation i have found out that the skaffold is not modifying the 'pg-example.yaml' file. For some reason it does not change the 'image' tag to the one that is built by skaffold. I think the answer lies in : https://skaffold.dev/docs/tutorials/skaffold-resource-selector/ ( still investigating )

amolgautam
  • 897
  • 10
  • 20

0 Answers0