Skip to content

Commit

Permalink
updates for OpenShift
Browse files Browse the repository at this point in the history
  • Loading branch information
steveww committed May 5, 2020
1 parent 9ecba3f commit c7b0f2a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 116 deletions.
2 changes: 2 additions & 0 deletions K8s/helm/templates/redis-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ spec:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
{{ if not .Values.openshift }}
storageClassName: standard
volumeMode: Filesystem
{{ end }}
resources:
requests:
storage: 1Gi
Expand Down
4 changes: 4 additions & 0 deletions K8s/helm/templates/web-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ spec:
targetPort: 8080
selector:
service: web
{{ if .Values.nodeport }}
type: NodePort
{{ else }}
type: LoadBalancer
{{ end }}
6 changes: 6 additions & 0 deletions K8s/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ eum:
psp:
enabled: false

# For the mini ones minikube, minishift set to true
nodeport: false

# "special" Openshift. Set to true when deploying to any openshift flavour
openshift: false

27 changes: 20 additions & 7 deletions OpenShift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@ See the official [documentation](https://docs.instana.io/quick_start/agent_setup

# Robot Shop Deployment

Have a look at the contents of the *setup.sh* and *deploy,sh* scripts, you may want to tweak some settings to suit your environment.
For OpenShift run the `setup.sh` script to create the project and set the extra permissions.

Run the *setup.sh* script first, you will need the passwords for the developer and system:admin users.
Use the Helm chart for Kubernetes to install Stan's Robot Shop. To install on Minishift.

Once the set up is completed, run the *deploy.sh* script. This script imports the application images from Docker Hub into OpenShift, then it creates applications from those images.
### Helm 3

When the deployment has completed, to make Stan's Robot Shop accessible the web service needs to be updated.
```shell
$ cd K8s
$ oc login -u developer
$ oc project robot-shop
$ helm install robot-shop --set openshift=true --set nodeport=true helm
```

To connect to the shop.

```bash
oc edit svc web
```shell
$ minishift ip
192.168.99.106
$ oc get svc web
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
web NodePort 172.30.180.253 <none> 8080:31147/TCP 4m
```

Change *type* to **NodePort** when running on Minishift or **LoadBalancer** for regular OpenShift.
Use the IP and the node port to form the URL `http://192.168.99.106:31147/`



48 changes: 0 additions & 48 deletions OpenShift/deploy.sh

This file was deleted.

22 changes: 3 additions & 19 deletions OpenShift/setup.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
#!/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
echo "logging in as system:admin"
oc login -u system:admin

# Optionally label the nodes with role infra
for NODE in $(oc get node | awk '{if ($3 == "infra" || $3 == "<none>") print $1}' -)
do
oc label node $NODE 'type=infra'
done

oc adm new-project robot-shop --node-selector='type=infra'
oc adm new-project robot-shop
oc adm policy add-role-to-user admin developer -n robot-shop
oc adm policy add-scc-to-user anyuid -z default
oc adm policy add-scc-to-user privileged -z default

oc logout

echo " "
echo "OpenShift set up complete, ready to deploy Robot Shop now."
echo " "
oc login -u developer

45 changes: 3 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,57 +70,18 @@ You can run Kubernetes locally using [minikube](https://github.com/kubernetes/mi

The Docker container images are all available on [Docker Hub](https://hub.docker.com/u/robotshop/).

Install Stan's Robot Shop to your Kubernetes cluster using the helm chart.

```shell
$ cd K8s/helm
$ helm install --name robot-shop --namespace robot-shop .
```

There are some customisations that can be made see the [README](K8s/helm/README.md).
Install Stan's Robot Shop to your Kubernetes cluster using the [Helm](K8s/helm/README.md) chart.

To deploy the Instana agent to Kubernetes, just use the [helm](https://hub.helm.sh/charts/stable/instana-agent) chart.

```shell
$ helm install --name instana-agent --namespace instana-agent \
--set agent.key=INSTANA_AGENT_KEY \
--set agent.endpointHost=HOST \
--set agent.endpointPort=PORT \
--set zone.name=CLUSTER_NAME \
stable/instana-agent
```

If you are having difficulties getting helm running with your K8s install, it is most likely due to RBAC, most K8s now have RBAC enabled by default. Therefore helm requires a [service account](https://github.com/helm/helm/blob/master/docs/rbac.md) to have permission to do stuff.

## Accessing the Store
If you are running the store locally via *docker-compose up* then, the store front is available on localhost port 8080 [http://localhost:8080](http://localhost:8080/)

If you are running the store on Kubernetes via minikube then, to make the store front accessible edit the *web* service definition and change the type to *NodePort* and add a port entry *nodePort: 30080*.

```shell
$ kubectl -n robot-shop edit service web
```

Snippet

```yaml
spec:
ports:
- name: "8080"
port: 8080
protocol: TCP
targetPort: 8080
nodePort: 30080
selector:
service: web
sessionAffinity: None
type: NodePort
```
The store front is then available on the IP address of minikube port 30080. To find the IP address of your minikube instance.
If you are running the store on Kubernetes via minikube then, find the IP address of Minikube and the Node Port of the web service.

```shell
$ minikube ip
$ kubectl get svc web
```

If you are using a cloud Kubernetes / Openshift / Mesosphere then it will be available on the load balancer of that system.
Expand Down

0 comments on commit c7b0f2a

Please sign in to comment.