The image name in initContainers should automatically resolve to a image stream name.
When using dc.spec.template.spec.initContainers and you set the image field to an image stream name, it isn't automatically resolved to an image stream name in the project as occurs for dc.spec.template.spec.containers. Being in a DeploymentConfig, I would expect it to, just like with normal containers in the pod. Instead it is necessary to set the lookupPolicy on the image stream to be local, or add the resolve-names annotation to the pod template.
Version
oc v3.6.1+008f2d5
kubernetes v1.6.1+5115d708d7
features: Basic-Auth
Server https://127.0.0.1:8443
openshift v3.6.1+008f2d5
kubernetes v1.6.1+5115d708d7
Steps To Reproduce
Use a oc patch --type=json patch such as:
[
{
"op": "add",
"path": "/spec/template/spec/initContainers",
"value": [
{
"name": "blog-htdocs-init",
"image": "blog",
"volumeMounts": [
{
"mountPath": "/mnt",
"name": "htdocs"
}
],
"command": [
"rsync",
"--archive",
"--no-perms",
"--no-times",
"/opt/app-root/src/htdocs/",
"/mnt/"
]
}
]
}
]
and the deployment will get stuck when trying to start the init container as it can't work out what image is.
Instead use:
[
{
"op": "add",
"path": "/spec/template/metadata/annotations/alpha.image.policy.openshift.io~1resolve-names",
"value": "*"
},
{
"op": "add",
"path": "/spec/template/spec/initContainers",
"value": [
{
"name": "blog-htdocs-init",
"image": "blog",
"volumeMounts": [
{
"mountPath": "/mnt",
"name": "htdocs"
}
],
"command": [
"rsync",
"--archive",
"--no-perms",
"--no-times",
"/opt/app-root/src/htdocs/",
"/mnt/"
]
}
]
}
]
or run:
oc set image-lookup dc/blog
which adds the annotation on the pod template, then works okay.
Current Result
Doesn't resolve image name to image stream in init containers.
Expected Result
Since part of DeploymentConfig, expect it to resolve to image stream name like it does for containers in same pod.
Additional Information
None.
@pweil- this is a deploymentconfig RFE, not an image RFE.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
/lifecycle frozen
+1
We are stuck with this as well. It means that you have to hard-code the image URI for the init-container in a template, which will fail if you don't match the project name to the template. This limits the usefulness of init-containers in a template, as there is no way to explicitly reference the namespace either: https://trello.com/c/zcRQFri0/916-2-namespace-template-parameter-templates.
@riekrh If the name of the image for the init container is the same as the main container, have you tried adding the name of the init container to the container names under imageChangeParams.
- imageChangeParams:
automatic: true
containerNames:
- superset
superset-init
from:
kind: ImageStreamTag
name: superset:latest
namespace: "${NAMESPACE}"
type: ImageChange
For the case where same image is used as main container, this works fine.
I'm still having this issue, even with declaring imageChangeParams + containerNames. @GrahamDumpleton can you post a complete example of the yaml where this approach works?
edit: nevermind, I was missing the image field having the image stream name as its value. now it looks to be working.
initContainers:
- name: ${APP_NAME}-init-alembic-migrate
image: ${APP_NAME} # <-- this is the image stream name
command: ["alembic", "upgrade", "head"]
env: *ENV