#1767·faas

支持在不使用补丁的情况下自定义功能图像

作者: eran-bt创建于 2022年11月15日更新于 2022年11月15日

My actions before raising this issue

Why do you need this?

I want to use different images for the same function, based on the environment in which the function runs (dev/staging/prod)

Who is this for?

Private usage. What company is this for? Are you listed in the ADOPTERS.md file?

Expected Behaviour

I would like the ability to define a Kustomization Component with image replacement, like this:

apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
images:
- name: tasks
  newName: registry/tasks
  newTag: dev
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
images:
- name: tasks
  newName: registry/tasks
  newTag: prod

And have it impact my base function definition:

apiVersion: openfaas.com/v1
kind: Function
metadata:
  name: tasks
  namespace: openfaas-fn
spec:
  name: tasks
  image: tasks

And within each env I will have the following kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base/tasks
components:
- ../dev/extension-api
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base/tasks
components:
- ../prod/extension-api

Such that when I run kubectl kustomize envs/dev/tasks The resulting yaml for the function would be:

apiVersion: openfaas.com/v1
kind: Function
metadata:
  name: tasks
  namespace: openfaas-fn
spec:
  name: tasks
  image: registry/tasks:dev

and when I run kubectl kustomize envs/prod/tasks The resulting yaml for the function would be:

apiVersion: openfaas.com/v1
kind: Function
metadata:
  name: tasks
  namespace: openfaas-fn
spec:
  name: tasks
  image: registry/tasks:prod

Current Behaviour

When defining the files as the above structure, the component is ignored, and running kubectl kustomize simply produces the same yaml as the base yaml, without replacing the image.

Are you a GitHub Sponsor (Yes/No?)

Check at: https://GitHub.com/sponsors/openfaas

  • Yes
  • No

List All Possible Solutions and Workarounds