Openshift: Unresolved Image

I had this same issue and I solved it by adding:

        lastTriggeredImage: >-
          mydockerrepo.com/repo/myimage@sha256:xxxxxxxxxxxxxxxx

On:

  triggers:
    - type: ImageChange
      imageChangeParams:

Of the deploymentconfig yaml. Looks like if it doesn't know what the last triggered image is, it wont be able to resolve it.


Included below is the template you can use as a starter. Just be aware that the grafana image appears to require it be run as root, else it will not startup. This means you have to override the default security model of OpenShift and enable allowing running of images as root in the project. This is not recommended. The grafana images should be fixed so as not to require they be run as root.

To enable running as root, you would need to run as a cluster admin:

oc adm policy add-scc-to-user anyuid -z default -n myproject

where myproject is the name of the project you are using.

I applied it to the default service account, but better you create a separate service account, apply it to that and then change the template so that only grafana runs as that service account.

It is possible that the intent is that you override the default settings through the grafana.ini file so it uses your mounted emptyDir directories and then it isn't an issue. I didn't attempt to provide any override config.

The template for grafana would then be as follows. Note I have used JSON as I find it easier to work with JSON, but also to avoid indenting being screwed up making the YAML impossible to use.

Before you use this template, you should obviously create the corresponding config map where name is of form ${APPLICATION_NAME}-config where ${APPLICATION_NAME} is grafana unless you override it when using the template. The key in the config map should be grafana.ini and then have as value the config file contents.

{
    "apiVersion": "v1",
    "kind": "Template",
    "metadata": {
        "name": "grafana"
    },
    "parameters": [
        {
            "name": "APPLICATION_NAME",
            "value": "grafana",
            "from": "[a-zA-Z0-9]",
            "required": true
        }
    ],
    "objects": [
        {
            "apiVersion": "v1",
            "kind": "ImageStream",
            "metadata": {
                "name": "${APPLICATION_NAME}-img",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "tags": [
                    {
                        "name": "latest",
                        "from": {
                            "kind": "DockerImage",
                            "name": "grafana/grafana"
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "v1",
            "kind": "DeploymentConfig",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "app": "${APPLICATION_NAME}",
                    "type": "monitoring"
                }
            },
            "spec": {
                "replicas": 1,
                "selector": {
                    "app": "${APPLICATION_NAME}",
                    "deploymentconfig": "${APPLICATION_NAME}"
                },
                "template": {
                    "metadata": {
                        "labels": {
                            "app": "${APPLICATION_NAME}",
                            "deploymentconfig": "${APPLICATION_NAME}",
                            "type": "monitoring"
                        }
                    },
                    "spec": {
                        "containers": [
                            {
                                "name": "grafana",
                                "image": "${APPLICATION_NAME}-img:latest",
                                "imagePullPolicy": "Always",
                                "livenessProbe": {
                                    "failureThreshold": 3,
                                    "httpGet": {
                                        "path": "/",
                                        "port": 3000,
                                        "scheme": "HTTP"
                                    },
                                    "periodSeconds": 10,
                                    "successThreshold": 1,
                                    "timeoutSeconds": 1
                                },
                                "ports": [
                                    {
                                        "containerPort": 3000,
                                        "protocol": "TCP"
                                    }
                                ],
                                "volumeMounts": [
                                    {
                                        "mountPath": "/etc/grafana",
                                        "name": "grafana-1"
                                    },
                                    {
                                        "mountPath": "/var/lib/grafana",
                                        "name": "grafana-2"
                                    },
                                    {
                                        "mountPath": "/var/log/grafana",
                                        "name": "grafana-3"
                                    }
                                ]
                            }
                        ],
                        "volumes": [
                            {
                                "configMap": {
                                    "defaultMode": 420,
                                    "name": "${APPLICATION_NAME}-config"
                                },
                                "name": "grafana-1"
                            },
                            {
                                "emptyDir": {},
                                "name": "grafana-2"
                            },
                            {
                                "emptyDir": {},
                                "name": "grafana-3"
                            }
                        ]
                    }
                },
                "test": false,
                "triggers": [
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "grafana"
                            ],
                            "from": {
                                "kind": "ImageStreamTag",
                                "name": "${APPLICATION_NAME}-img:latest"
                            }
                        },
                        "type": "ImageChange"
                    }
                ]
            }
        },
        {
            "apiVersion": "v1",
            "kind": "Service",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "app": "${APPLICATION_NAME}",
                    "type": "monitoring"
                }
            },
            "spec": {
                "ports": [
                    {
                        "name": "3000-tcp",
                        "port": 3000,
                        "protocol": "TCP",
                        "targetPort": 3000
                    }
                ],
                "selector": {
                    "deploymentconfig": "${APPLICATION_NAME}"
                },
                "type": "ClusterIP"
            }
        },
        {
            "apiVersion": "v1",
            "kind": "Route",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "app": "${APPLICATION_NAME}",
                    "type": "monitoring"
                }
            },
            "spec": {
                "host": "",
                "port": {
                    "targetPort": "3000-tcp"
                },
                "to": {
                    "kind": "Service",
                    "name": "${APPLICATION_NAME}",
                    "weight": 100
                }
            }
        }
    ]
}