updates for OpenShift
This commit is contained in:
@@ -39,8 +39,10 @@ spec:
|
|||||||
name: data
|
name: data
|
||||||
spec:
|
spec:
|
||||||
accessModes: [ "ReadWriteOnce" ]
|
accessModes: [ "ReadWriteOnce" ]
|
||||||
|
{{ if not .Values.openshift }}
|
||||||
storageClassName: standard
|
storageClassName: standard
|
||||||
volumeMode: Filesystem
|
volumeMode: Filesystem
|
||||||
|
{{ end }}
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 1Gi
|
storage: 1Gi
|
||||||
|
@@ -11,4 +11,8 @@ spec:
|
|||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
selector:
|
selector:
|
||||||
service: web
|
service: web
|
||||||
|
{{ if .Values.nodeport }}
|
||||||
|
type: NodePort
|
||||||
|
{{ else }}
|
||||||
type: LoadBalancer
|
type: LoadBalancer
|
||||||
|
{{ end }}
|
||||||
|
@@ -21,3 +21,9 @@ eum:
|
|||||||
psp:
|
psp:
|
||||||
enabled: false
|
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
|
||||||
|
|
||||||
|
@@ -4,17 +4,30 @@ See the official [documentation](https://docs.instana.io/quick_start/agent_setup
|
|||||||
|
|
||||||
# Robot Shop Deployment
|
# 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
|
||||||
```bash
|
$ oc login -u developer
|
||||||
oc edit svc web
|
$ oc project robot-shop
|
||||||
|
$ helm install robot-shop --set openshift=true --set nodeport=true helm
|
||||||
```
|
```
|
||||||
|
|
||||||
Change *type* to **NodePort** when running on Minishift or **LoadBalancer** for regular OpenShift.
|
To connect to the shop.
|
||||||
|
|
||||||
|
```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
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the IP and the node port to form the URL `http://192.168.99.106:31147/`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# set -x
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Put your EUM key here
|
|
||||||
EUM_KEY=""
|
|
||||||
|
|
||||||
|
|
||||||
echo "logging in as developer"
|
|
||||||
oc login -u developer
|
|
||||||
oc project robot-shop
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
echo " "
|
|
||||||
echo "Deployment complete"
|
|
||||||
echo "To make Robot Shop accessible, please run <oc edit svc web>"
|
|
||||||
echo "Change type from ClusterIP to NodePort on minishift or LoadBalancer on OpenShift"
|
|
||||||
echo " "
|
|
||||||
|
|
@@ -1,28 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Put your EUM key here
|
|
||||||
EUM_KEY=""
|
|
||||||
|
|
||||||
# set -x
|
# 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
|
oc login -u system:admin
|
||||||
|
oc adm new-project robot-shop
|
||||||
# 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 policy add-role-to-user admin developer -n 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 anyuid -z default
|
||||||
|
oc adm policy add-scc-to-user privileged -z default
|
||||||
|
|
||||||
oc logout
|
oc login -u developer
|
||||||
|
|
||||||
echo " "
|
|
||||||
echo "OpenShift set up complete, ready to deploy Robot Shop now."
|
|
||||||
echo " "
|
|
||||||
|
|
||||||
|
45
README.md
45
README.md
@@ -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/).
|
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.
|
Install Stan's Robot Shop to your Kubernetes cluster using the [Helm](K8s/helm/README.md) 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).
|
|
||||||
|
|
||||||
To deploy the Instana agent to Kubernetes, just use the [helm](https://hub.helm.sh/charts/stable/instana-agent) 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
|
## 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 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*.
|
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
|
|
||||||
$ 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.
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ minikube ip
|
$ 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.
|
If you are using a cloud Kubernetes / Openshift / Mesosphere then it will be available on the load balancer of that system.
|
||||||
|
Reference in New Issue
Block a user