{
  "kind": "Template",
  "apiVersion": "v1",
  "metadata": {
    "name": "jenkins-ephemeral",
    "annotations": {
      "openshift.io/display-name": "Jenkins (Ephemeral)",
      "description": "Jenkins service, without persistent storage.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.",
      "iconClass": "icon-jenkins",
      "tags": "instant-app,jenkins",
      "openshift.io/long-description": "This template deploys a Jenkins server capable of managing OpenShift Pipeline builds and supporting OpenShift-based oauth login.  The Jenkins configuration is stored in non-persistent storage, so this configuration should be used for experimental purposes only.",
      "openshift.io/provider-display-name": "Red Hat, Inc.",
      "openshift.io/documentation-url": "https://docs.okd.io/latest/using_images/other_images/jenkins.html",
      "openshift.io/support-url": "https://access.redhat.com"
    }
  },
  "message": "A Jenkins service has been created in your project.  Log into Jenkins with your OpenShift account.  The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.",
  "labels": {
    "app": "jenkins-ephemeral",
    "template": "jenkins-ephemeral-template"
  },
  "objects": [
    {
      "kind": "Route",
      "apiVersion": "v1",
      "metadata": {
        "name": "${JENKINS_SERVICE_NAME}",
        "annotations": {
          "template.openshift.io/expose-uri": "http://{.spec.host}{.spec.path}",
          "haproxy.router.openshift.io/timeout": "4m"
        }
      },
      "spec": {
        "to": {
          "kind": "Service",
          "name": "${JENKINS_SERVICE_NAME}"
        },
        "tls": {
          "termination": "edge",
          "insecureEdgeTerminationPolicy": "Redirect"
        }
      }
    },
    {
      "kind": "ConfigMap",
      "apiVersion": "v1",
      "metadata": {
        "name": "${JENKINS_SERVICE_NAME}-trusted-ca-bundle",
        "labels": {
          "config.openshift.io/inject-trusted-cabundle": "true"
        }
      }
    },
    {
      "kind": "DeploymentConfig",
      "apiVersion": "v1",
      "metadata": {
        "name": "${JENKINS_SERVICE_NAME}",
        "annotations": {
          "template.alpha.openshift.io/wait-for-ready": "true"
        }
      },
      "spec": {
        "strategy": {
          "type": "Recreate"
        },
        "triggers": [
          {
            "type": "ImageChange",
            "imageChangeParams": {
              "automatic": true,
              "containerNames": [
                "jenkins"
              ],
              "from": {
                "kind": "ImageStreamTag",
                "name": "${JENKINS_IMAGE_STREAM_TAG}",
                "namespace": "${NAMESPACE}"
              },
              "lastTriggeredImage": ""
            }
          },
          {
            "type": "ConfigChange"
          }
        ],
        "replicas": 1,
        "selector": {
          "name": "${JENKINS_SERVICE_NAME}"
        },
        "template": {
          "metadata": {
            "labels": {
              "name": "${JENKINS_SERVICE_NAME}"
            }
          },
          "spec": {
            "serviceAccountName": "${JENKINS_SERVICE_NAME}",
            "containers": [
              {
                "name": "jenkins",
                "image": " ",
                "readinessProbe": {
                  "timeoutSeconds": 240,
                  "initialDelaySeconds": 3,
                  "httpGet": {
                    "path": "/login",
                    "port": 8080
                  }
                },
                "livenessProbe": {
                    "timeoutSeconds": 240,
                    "periodSeconds": 360,
                    "initialDelaySeconds": 420,
                    "failureThreshold" : 2,
                    "httpGet": {
                        "path": "/login",
                        "port": 8080
                    }
                },
                "env": [
                  {
                    "name": "OPENSHIFT_ENABLE_OAUTH",
                    "value": "${ENABLE_OAUTH}"
                  },
                  {
                    "name": "OPENSHIFT_ENABLE_REDIRECT_PROMPT",
                    "value": "true"
                  },
                  {
                    "name": "DISABLE_ADMINISTRATIVE_MONITORS",
                    "value": "${DISABLE_ADMINISTRATIVE_MONITORS}"
                  },
                  {
                    "name": "KUBERNETES_MASTER",
                    "value": "https://kubernetes.default:443"
                  },
                  {
                    "name": "KUBERNETES_TRUST_CERTIFICATES",
                    "value": "true"
                  },
                  {
                    "name": "JENKINS_SERVICE_NAME",
                    "value": "${JENKINS_SERVICE_NAME}"
                  },
                  {
                    "name": "JNLP_SERVICE_NAME",
                    "value": "${JNLP_SERVICE_NAME}"
                  },
                  {
                    "name": "JENKINS_UC_INSECURE",
                    "value": "${JENKINS_UC_INSECURE}"
                  },
                  {
                    "name": "CASC_JENKINS_CONFIG",
                    "value": "/var/lib/jenkins/proxy.yaml"
                  },
                  {
                    "name": "JAVA_FIPS_OPTIONS",
                    "value": "${JAVA_FIPS_OPTIONS}"
                  }
                ],
                "resources": {
                  "limits": {
                    "memory": "${MEMORY_LIMIT}"
                  }
                },
                "volumeMounts": [
                  {
                    "name": "${JENKINS_SERVICE_NAME}-data",
                    "mountPath": "/var/lib/jenkins"
                  },
                  {
                    "name": "${JENKINS_SERVICE_NAME}-trusted-ca-bundle",
                    "mountPath": "/etc/pki/ca-trust/source/anchors"
                  }
                ],
                "terminationMessagePath": "/dev/termination-log",
                "imagePullPolicy": "IfNotPresent",
                "capabilities": {},
                "securityContext": {
                  "capabilities": {},
                  "privileged": false
                }
              }
            ],
            "volumes": [
              {
                "name": "${JENKINS_SERVICE_NAME}-data",
                "emptyDir": {
                  "medium": ""
                }
              },
              {
                "name": "${JENKINS_SERVICE_NAME}-trusted-ca-bundle",
                "configMap": {
                  "name": "${JENKINS_SERVICE_NAME}-trusted-ca-bundle",
                  "optional": true
                }
              }
            ],
            "restartPolicy": "Always",
            "dnsPolicy": "ClusterFirst"
          }
        }
      }
    },
    {
      "kind": "ServiceAccount",
        "apiVersion": "v1",
        "metadata": {
            "name": "${JENKINS_SERVICE_NAME}",
            "annotations": {
		"serviceaccounts.openshift.io/oauth-redirectreference.jenkins": "{\"kind\":\"OAuthRedirectReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Route\",\"name\":\"${JENKINS_SERVICE_NAME}\"}}"
            }
        }
    },
    {
      "kind": "RoleBinding",
      "apiVersion": "v1",
      "metadata": {
          "name": "${JENKINS_SERVICE_NAME}_edit"
      },
      "groupNames": null,
      "subjects": [
          {
              "kind": "ServiceAccount",
              "name": "${JENKINS_SERVICE_NAME}"
          }
      ],
      "roleRef": {
          "name": "edit"
      }
    },
    {
      "kind": "Service",
      "apiVersion": "v1",
      "metadata": {
        "name": "${JNLP_SERVICE_NAME}"
      },
      "spec": {
        "ports": [
          {
            "name": "agent",
            "protocol": "TCP",
            "port": 50000,
            "targetPort": 50000,
            "nodePort": 0
          }
        ],
        "selector": {
          "name": "${JENKINS_SERVICE_NAME}"
        },
        "type": "ClusterIP",
        "sessionAffinity": "None"
      }
    },
    {
       "kind": "Service",
       "apiVersion": "v1",
       "metadata": {
         "name": "${JENKINS_SERVICE_NAME}",
         "annotations": {
           "service.alpha.openshift.io/dependencies": "[{\"name\": \"${JNLP_SERVICE_NAME}\", \"namespace\": \"\", \"kind\": \"Service\"}]",
           "service.openshift.io/infrastructure": "true"
         }
       },
       "spec": {
         "ports": [
           {
             "name": "web",
             "protocol": "TCP",
             "port": 80,
             "targetPort": 8080,
             "nodePort": 0
           }
         ],
         "selector": {
           "name": "${JENKINS_SERVICE_NAME}"
         },
         "type": "ClusterIP",
         "sessionAffinity": "None"
       }
    }
  ],
  "parameters": [
    {
      "name": "JENKINS_SERVICE_NAME",
      "displayName": "Jenkins Service Name",
      "description": "The name of the OpenShift Service exposed for the Jenkins container.",
      "value": "jenkins"
    },
    {
      "name": "JNLP_SERVICE_NAME",
      "displayName": "Jenkins JNLP Service Name",
      "description": "The name of the service used for master/slave communication.",
      "value": "jenkins-jnlp"
    },
    {
      "name": "ENABLE_OAUTH",
      "displayName": "Enable OAuth in Jenkins",
      "description": "Whether to enable OAuth OpenShift integration. If false, the static account 'admin' will be initialized with the password 'password'.",
      "value": "true"
    },
    {
      "name": "MEMORY_LIMIT",
      "displayName": "Memory Limit",
      "description": "Maximum amount of memory the container can use.",
      "value": "1Gi"
    },
    {
      "name": "NAMESPACE",
      "displayName": "Jenkins ImageStream Namespace",
      "description": "The OpenShift Namespace where the Jenkins ImageStream resides.",
      "value": "openshift"
    },
    {
      "name": "DISABLE_ADMINISTRATIVE_MONITORS",
      "displayName": "Disable memory intensive administrative monitors",
      "description": "Whether to perform memory intensive, possibly slow, synchronization with the Jenkins Update Center on start.  If true, the Jenkins core update monitor and site warnings monitor are disabled.",
      "value": "false"
    },
    {
      "name": "JAVA_FIPS_OPTIONS",
      "displayName": "Allows control over how the JVM interacts with FIPS on startup.",
      "description": "See https://access.redhat.com/documentation/en-us/openjdk/11/html-single/configuring_openjdk_11_on_rhel_with_fips/index#config-fips-in-openjdk for the available command line properties to facilitate the JVM running on FIPS nodes.",
      "value": "-Dcom.redhat.fips=false"
    },
    {
      "name": "JENKINS_IMAGE_STREAM_TAG",
      "displayName": "Jenkins ImageStreamTag",
      "description": "Name of the ImageStreamTag to be used for the Jenkins image.",
      "value": "jenkins:2"
    },
    {
      "name": "JENKINS_UC_INSECURE",
      "displayName": "Allows use of Jenkins Update Center repository with invalid SSL certificate",
      "description": "Whether to allow use of a Jenkins Update Center that uses invalid certificate (self-signed, unknown CA). If any value other than 'false', certificate check is bypassed. By default, certificate check is enforced.",
      "value": "false"
    }
  ]
}
