Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kustomize Replacement and prefix Issue: prefix container registry host to Image with missing registry and Registry Replacements for existing images #5828

Open
aditi-sharma27 opened this issue Dec 24, 2024 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@aditi-sharma27
Copy link

aditi-sharma27 commented Dec 24, 2024

What happened?

I'm working on a Kustomize setup where I need to: Download all images from my local registry i.e 10.20.30.40
I didn't find any generic way to point out the image registry to my local registry. like in Helm way we set
global:
registry: "10.20.30.40" # Your global registry URL

Replace the registry for images that already have a registry (e.g., docker.io → 10.20.30.40). Prepend the registry for images without one (e.g., mysql:8.0.29 → 10.20.30.40/mysql:8.0.29).

I tried image prefix as well, thats prefixing to all images and not doing replacement. Not I am trying replacement and its replacing all images first position.

What did you expect to happen?

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    katib.kubeflow.org/component: mysql
  name: katib-mysql
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      katib.kubeflow.org/component: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
      labels:
        katib.kubeflow.org/component: mysql
    spec:
      containers:
      - args:
        - --datadir
        - /var/lib/mysql/datadir
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              key: MYSQL_ROOT_PASSWORD
              name: katib-mysql-secrets
        - name: MYSQL_ALLOW_EMPTY_PASSWORD
          value: "true"
        - name: MYSQL_DATABASE
          value: katib
        image: 10.20.30.40 ----here i want ip followed by original image mysql:8.0.29 and expected is 10.20.30.40/mysql:8.0.29
        livenessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}
          failureThreshold: 10
          initialDelaySeconds: 10
          periodSeconds: 5
        name: katib-mysql
        ports:
        - containerPort: 3306
          name: dbapi
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysql -D ${MYSQL_DATABASE} -u root -p${MYSQL_ROOT_PASSWORD} -e 'SELECT
              1'
          failureThreshold: 10
          initialDelaySeconds: 10
          periodSeconds: 5
        startupProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}
          failureThreshold: 60
          periodSeconds: 15
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: katib-mysql
      volumes:
      - name: katib-mysql
        persistentVolumeClaim:
          claimName: katib-mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    katib.kubeflow.org/component: ui
  name: katib-ui
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      katib.kubeflow.org/component: ui
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
      labels:
        katib.kubeflow.org/component: ui
    spec:
      containers:
      - args:
        - --port=8080
        command:
        - ./katib-ui
        env:
        - name: KATIB_CORE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: APP_DISABLE_AUTH
          value: "false"
        image: 10.20.30.40/kubeflowkatib/katib-ui:v0.17.0  ----- this is correct as expected
        name: katib-ui
        ports:
        - containerPort: 8080
          name: ui
      serviceAccountName: katib-ui

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
resources:
- test_two.yaml

replacements:
- source:
    kind: ConfigMap
    name: local-config
    fieldPath: data.registry
  targets:
  - select:
      kind: Deployment
    fieldPaths:
    - spec.template.spec.containers.*.image
    options:
      delimiter: "/"
      index: 0
#test_two.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: local-config
  annotations:
    config.kubernetes.io/local-config: "true"
data:
  registry: "10.20.30.40"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    katib.kubeflow.org/component: mysql
  name: katib-mysql
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      katib.kubeflow.org/component: mysql
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
      labels:
        katib.kubeflow.org/component: mysql
    spec:
      containers:
      - args:
        - --datadir
        - /var/lib/mysql/datadir
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: katib-mysql-secrets
              key: MYSQL_ROOT_PASSWORD
        - name: MYSQL_ALLOW_EMPTY_PASSWORD
          value: "true"
        - name: MYSQL_DATABASE
          value: "katib"
        image: mysql:8.0.29
        name: katib-mysql
        ports:
        - containerPort: 3306
          name: dbapi
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysql -D ${MYSQL_DATABASE} -u root -p${MYSQL_ROOT_PASSWORD} -e 'SELECT 1'
          initialDelaySeconds: 10
          periodSeconds: 5
          failureThreshold: 10
        livenessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}
          initialDelaySeconds: 10
          periodSeconds: 5
          failureThreshold: 10
        startupProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}
          periodSeconds: 15
          failureThreshold: 60
        volumeMounts:
        - name: katib-mysql
          mountPath: /var/lib/mysql
      volumes:
      - name: katib-mysql
        persistentVolumeClaim:
          claimName: katib-mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    katib.kubeflow.org/component: ui
  name: katib-ui
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      katib.kubeflow.org/component: ui
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
      labels:
        katib.kubeflow.org/component: ui
    spec:
      containers:
      - args:
        - --port=8080
        command:
        - ./katib-ui
        env:
        - name: KATIB_CORE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: APP_DISABLE_AUTH
          value: "false"
        image: docker.io/kubeflowkatib/katib-ui:v0.17.0
        name: katib-ui
        ports:
        - containerPort: 8080
          name: ui
      serviceAccountName: katib-ui

Expected output

Actual output

Kustomize version

v5.4.3

Operating system

Linux

@aditi-sharma27 aditi-sharma27 added the kind/bug Categorizes issue or PR as related to a bug. label Dec 24, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 24, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants