= Install OKD _(Openshift Origin)_

== Pre-requisites

=== Install docker

https://docs.docker.com/engine/installation/linux/docker-ce/debian/#set-up-the-repository

[source,Shell]
----
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
----

=== Download Openshift Origin Client

Download Openshift Origin Client from https://www.openshift.org/download.html#oc-platforms[here]

When the download it's complete, only extract it on the directory that you want, for example `/home/administrador/oc`

////
```
wget https://github.com/openshift/origin/releases/download/v3.7.1/openshift-origin-server-v3.7.1-ab0f056-linux-64bit.tar.gz

tar -xvzf openshift-origin-server-v3.7.1-ab0f056-linux-64bit.tar.gz
mv openshift-origin-server-v3.7.1-ab0f056-linux-64bit oc
```
////

=== Add oc to path

[source,Shell]
----
$ export PATH=$PATH:/home/administrador/oc
----

== Install Openshift Cluster

=== Add the insecure registry

Create file ```/etc/docker/daemon.json``` with the next content:

[source,json]
----
{
    "insecure-registries" : [ "172.30.0.0/16" ]
}
----

=== Download docker images for openshift

[source,Shell]
----
$ oc cluster up
----

== Install Oc Cluster Wrapper

To manage easier the cluster persistent, we are going to use oc cluster wrapper.

[source,Shell]
----
cd /home/administrador/oc
wget https://raw.githubusercontent.com/openshift-evangelists/oc-cluster-wrapper/master/oc-cluster
----

oc-cluster up devonfw-shop-floor --public-hostname X.X.X.X

=== Configure iptables

We must create iptables rules to allow traffic from other machines.

```diff
- The next commands it's to let all traffic, don't do it on a real server.

- $ iptables -F
- $ iptables -X
- $ iptables -t nat -F
- $ iptables -t nat -X
- $ iptables -t mangle -F
- $ iptables -t mangle -X
- $ iptables -P INPUT ACCEPT
- $ iptables -P OUTPUT ACCEPT
- $ iptables -P FORWARD ACCEPT
```

= How to use Oc Cluster Wrapper

With oc cluster wrapper we could have different clusters with different context.

== Cluster up

[source,Shell]
----
$ oc-cluster up devonfw-shop-floor --public-hostname X.X.X.X
----

== Cluster down

[source,Shell]
----
$ oc-cluster down
----

== Use non-persistent cluster

[source,Shell]
----
oc cluster up --image openshift/origin --public-hostname X.X.X.X --routing-suffix apps.X.X.X.X.nip.io
----
