Skip to content

Instantly share code, notes, and snippets.

@developerinlondon
Last active November 7, 2017 11:11
Show Gist options
  • Save developerinlondon/b5dcae0d30b96c0b466436da50b6057f to your computer and use it in GitHub Desktop.
Save developerinlondon/b5dcae0d30b96c0b466436da50b6057f to your computer and use it in GitHub Desktop.
---
- name: Spring Example | Check if Project Exists
shell: oc projects | grep spring-example
register: project_exists
ignore_errors: yes
- block:
- name: Spring Example | Create Spring Project
command: oc new-project spring-example
- name: Spring Example | Creating Build
command: oc new-build registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift~https://github.com/raffaelespazzoli/credscontroller --context-dir=examples/spring-example --name spring-example
- name: Spring Example | Creating Spring Example Application
command: oc create -f {{ playbook_dir }}/openshift-postinstall/files/spring-example.yaml
- name: Spring Example | Exposing Spring route
command: oc expose svc spring-example
when: "(project_exists.rc != 0)"
apiVersion: v1
kind: Service
metadata:
labels:
app: spring-example
name: spring-example
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: spring-example
---
apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: spring-example
name: spring-example
spec:
triggers:
-
type: ConfigChange
-
type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- spring-example
from:
kind: ImageStreamTag
namespace: spring-example
name: 'spring-example:latest'
replicas: 1
template:
metadata:
labels:
app: spring-example
annotations:
vaultproject.io/policies: default,spring-example
vaultproject.io/ttl: "24h"
pod.beta.kubernetes.io/init-containers: '[
{
"name": "vault-init",
"image": "raffaelespazzoli/credscontroller:0.0.1",
"args": ["vault-init"],
"imagePullPolicy": "Always",
"ports" : [
{
"containerPort" : 8443,
"name" : "init-port",
"protocol" : "TCP"
}
],
"env": [
{
"name": "POD_NAME",
"valueFrom": {"fieldRef": {"fieldPath": "metadata.name", "apiVersion": "v1"}}
},
{
"name": "POD_IP",
"valueFrom": {"fieldRef": {"fieldPath": "status.podIP", "apiVersion": "v1"}}
},
{
"name": "POD_NAMESPACE",
"valueFrom": {"fieldRef": {"fieldPath": "metadata.namespace", "apiVersion": "v1"}}
},
{
"name": "VAULT_CACERT",
"value": "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
},
{
"name": "VAULT_ADDR",
"value": "https://vault.vault-controller.svc.cluster.local:8200"
},
{
"name": "VAULT_CONTROLLER_ADDR",
"value": "https://vault-controller.vault-controller.svc.cluster.local:8443"
},
{
"name": "VAULT_CONTROLLER_CACERT",
"value": "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
},
{
"name": "VAULT_INIT_PORT",
"value": "8443"
},
{
"name": "LOG_LEVEL",
"value": "debug"
}
],
"volumeMounts": [
{
"name": "vault-token",
"mountPath": "/var/run/secrets/vaultproject.io"
}
]
}
]'
spec:
containers:
- name: spring-example
image: "spring-example/spring-example:latest"
imagePullPolicy: Always
env:
- name: "VAULT_CACERT"
value: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
- name: "VAULT_HOST"
value: "vault.vault-controller.svc.cluster.local"
- name: "VAULT_PORT"
value: "8200"
- name: "VAULT_TOKEN_FILE"
value: "/var/run/secrets/vaultproject.io/secret.json"
# determine the context of the generic backend
- name: SPRING_CLOUD_VAULT_GENERIC_APPLICATION_NAME
value: spring-example
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 60
periodSeconds: 3
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 60
periodSeconds: 3
volumeMounts:
- name: vault-token
mountPath: "/var/run/secrets/vaultproject.io"
volumes:
- name: vault-token
emptyDir:
medium: Memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment