Skip to content

Commit

Permalink
OpenShift deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
steveww committed Mar 14, 2018
1 parent 535dd40 commit c0ba0fc
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 0 deletions.
18 changes: 18 additions & 0 deletions OpenShift/agent-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

if [ "$1" = "p" ]
then
YAML=instana-agent-os-private.yaml
else
YAML=instana-agent-os.yaml
fi

oc login -u system:admin
oc create -f $YAML
oc project instana-agent
oc adm policy add-scc-to-user privileged -z instana-admin
oc label node localhost agent=instana
oc adm policy add-role-to-user admin developer -n instana-agent

oc login -u developer

49 changes: 49 additions & 0 deletions OpenShift/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

# Put your EUM key here
EUM_KEY=""

# set -x

# This only works for default local install of minishift
# Need to tweak some settings in OpenShift
oc login -u developer
oc new-project robot-shop
oc login -u system:admin
oc adm policy add-scc-to-user anyuid system:serviceaccount:robot-shop:default
oc login -u developer
oc project robot-shop

echo "OpenShift set up complete, ready to deploy Robot Shop now."
/bin/echo -n "Enter to continue: "
read CONTINUE

# set the environment from the .env file
for VAR in $(egrep '^[A-Z]+=' ../.env)
do
export $VAR
done


# import all the images from docker hub into OpenShift
for LINE in $(awk '/^ {2}[a-z]+:$/ {printf "%s", $0} /image: / {print $2}' ../docker-compose.yaml)
do
NAME=$(echo "$LINE" | cut -d: -f1)
IMAGE=$(echo "$LINE" | cut -d: -f2-)
FULL_IMAGE=$(eval "echo $IMAGE")

echo "NAME $NAME"
echo "importing $FULL_IMAGE"

oc import-image $FULL_IMAGE --from $FULL_IMAGE --confirm
# a bit of a hack but appears to work
BASE=$(basename $FULL_IMAGE)
oc new-app -i $BASE --name $NAME
done

# Set EUM environment if required
if [ -n "$EUM_KEY" ]
then
oc set env dc/web INSTANA_EUM_KEY=$EUM_KEY
fi

114 changes: 114 additions & 0 deletions OpenShift/instana-agent-os.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apiVersion: v1
kind: List
items:
- kind: Namespace
apiVersion: v1
metadata:
name: instana-agent
labels:
name: instana-agent

- apiVersion: v1
kind: ServiceAccount
metadata:
name: instana-admin
namespace: instana-agent

- apiVersion: v1
kind: Secret
metadata:
name: instana-agent-secret
namespace: instana-agent
data:
key: <your base64 encoded key here>

- apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
labels:
app: instana-agent
name: instana-agent
namespace: instana-agent
spec:
selector:
matchLabels:
app: instana-agent
template:
metadata:
labels:
app: instana-agent
spec:
nodeSelector:
agent: instana
hostIPC: true
hostNetwork: true
hostPID: true
containers:
- name: instana-agent
image: instana/agent
imagePullPolicy: Always
env:
- name: INSTANA_ZONE
value: Stans-Robot-Shop
- name: INSTANA_AGENT_ENDPOINT
value: saas-us-west-2.instana.io
- name: INSTANA_AGENT_ENDPOINT_PORT
value: '443'
- name: INSTANA_AGENT_HTTP_LISTEN
value: '*'
- name: INSTANA_AGENT_KEY
valueFrom:
secretKeyRef:
name: instana-agent-secret
key: key
securityContext:
privileged: true
volumeMounts:
- name: dev
mountPath: /dev
- name: run
mountPath: /var/run/docker.sock
- name: sys
mountPath: /sys
- name: log
mountPath: /var/log
livenessProbe:
exec:
command:
- echo
- noop
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
readinessProbe:
exec:
command:
- echo
- noop
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
resources:
requests:
memory: "256Mi"
cpu: "0.2"
limits:
memory: "512Mi"
cpu: "0.5"
volumes:
- name: dev
hostPath:
path: /dev
- name: run
hostPath:
path: /var/run/docker.sock
- name: sys
hostPath:
path: /sys
- name: log
hostPath:
path: /var/log
serviceAccount: instana-admin

0 comments on commit c0ba0fc

Please sign in to comment.