text stringlengths 0 59.1k |
|---|
kind: Namespace |
apiVersion: v1 |
metadata: |
name: "openshift-origin" |
labels: |
name: "openshift-origin" |
<|endoftext|> |
# source: k8s_examples/_archived/openshift-origin/README.md type: docs |
## OpenShift Origin example |
This example shows how to run OpenShift Origin as a pod on an existing Kubernetes cluster. |
OpenShift Origin runs with a rich set of role based policy rules out of the box that requires authentication from users via certificates. When run as a pod on an existing Kubernetes cluster, it proxies access to the underlying Kubernetes services to provide security. |
As a result, this example is a complex end-to-end configuration that shows how to configure certificates for a service that runs on Kubernetes, and requires a number of configuration files to be injected dynamically via a secret volume to the pod. |
This example will create a pod running the OpenShift Origin master. In addition, it will run a three-pod etcd setup to hold OpenShift content. OpenShift embeds Kubernetes in the stand-alone setup, so the configuration for OpenShift when it is running against an external Kubernetes cluster is different: content specific... |
### Step 0: Prerequisites |
This example assumes that you have an understanding of Kubernetes and that you have forked the repository. |
OpenShift Origin creates privileged containers when running Docker builds during the source-to-image process. |
If you are using a Salt based KUBERNETES_PROVIDER (**gce**, **vagrant**, **aws**), you should enable the |
ability to create privileged containers via the API. |
```sh |
$ cd kubernetes |
$ vi cluster/saltbase/pillar/privilege.sls |
# If true, allow privileged containers to be created by API |
allow_privileged: true |
``` |
Now spin up a cluster using your preferred KUBERNETES_PROVIDER. Remember that `kube-up.sh` may start other pods on your nodes, so ensure that you have enough resources to run the five pods for this example. |
```sh |
$ export KUBERNETES_PROVIDER=${YOUR_PROVIDER} |
$ cluster/kube-up.sh |
``` |
Next, let's setup some variables, and create a local folder that will hold generated configuration files. |
```sh |
$ export OPENSHIFT_EXAMPLE=$(pwd)/examples/openshift-origin |
$ export OPENSHIFT_CONFIG=${OPENSHIFT_EXAMPLE}/config |
$ mkdir ${OPENSHIFT_CONFIG} |
$ export ETCD_INITIAL_CLUSTER_TOKEN=$(python -c "import string; import random; print(''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(40)))") |
$ export ETCD_DISCOVERY_TOKEN=$(python -c "import string; import random; print(\"etcd-cluster-\" + ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(5)))") |
$ sed -i.bak -e "s/INSERT_ETCD_INITIAL_CLUSTER_TOKEN/\"${ETCD_INITIAL_CLUSTER_TOKEN}\"/g" -e "s/INSERT_ETCD_DISCOVERY_TOKEN/\"${ETCD_DISCOVERY_TOKEN}\"/g" ${OPENSHIFT_EXAMPLE}/etcd-controller.yaml |
``` |
This will have created a `etcd-controller.yaml.bak` file in your directory, which you should remember to restore when doing cleanup (or use the given `cleanup.sh`). Finally, let's start up the external etcd pods and the discovery service necessary for their initialization: |
```sh |
$ kubectl create -f examples/openshift-origin/openshift-origin-namespace.yaml |
$ kubectl create -f examples/openshift-origin/etcd-discovery-controller.yaml --namespace="openshift-origin" |
$ kubectl create -f examples/openshift-origin/etcd-discovery-service.yaml --namespace="openshift-origin" |
$ kubectl create -f examples/openshift-origin/etcd-controller.yaml --namespace="openshift-origin" |
$ kubectl create -f examples/openshift-origin/etcd-service.yaml --namespace="openshift-origin" |
``` |
### Step 1: Export your Kubernetes configuration file for use by OpenShift pod |
OpenShift Origin uses a configuration file to know how to access your Kubernetes cluster with administrative authority. |
``` |
$ cluster/kubectl.sh config view --output=yaml --flatten=true --minify=true > ${OPENSHIFT_CONFIG}/kubeconfig |
``` |
The output from this command will contain a single file that has all the required information needed to connect to your Kubernetes cluster that you previously provisioned. This file should be considered sensitive, so do not share this file with untrusted parties. |
We will later use this file to tell OpenShift how to bootstrap its own configuration. |
### Step 2: Create an External Load Balancer to Route Traffic to OpenShift |
An external load balancer is needed to route traffic to our OpenShift master service that will run as a pod on your Kubernetes cluster. |
```sh |
$ cluster/kubectl.sh create -f $OPENSHIFT_EXAMPLE/openshift-service.yaml --namespace="openshift-origin" |
``` |
### Step 3: Generate configuration file for your OpenShift master pod |
The OpenShift master requires a configuration file as input to know how to bootstrap the system. |
In order to build this configuration file, we need to know the public IP address of our external load balancer in order to build default certificates. |
Grab the public IP address of the service we previously created: the two-line script below will attempt to do so, but make sure to check that the IP was set as a result - if it was not, try again after a couple seconds. |
```sh |
$ export PUBLIC_OPENSHIFT_IP=$(kubectl get services openshift --namespace="openshift-origin" --template="{{ index .status.loadBalancer.ingress 0 \"ip\" }}") |
$ echo ${PUBLIC_OPENSHIFT_IP} |
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.