{"id":1525,"date":"2019-03-27T20:14:00","date_gmt":"2019-03-27T20:14:00","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=1525"},"modified":"2019-04-06T01:30:14","modified_gmt":"2019-04-06T01:30:14","slug":"install-openshift-in-a-container-with-weave-footloose","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/03\/27\/install-openshift-in-a-container-with-weave-footloose\/","title":{"rendered":"Install OpenShift in a container with Weave Footloose"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1590\" src=\"http:\/\/www.appservgrid.com\/paw93\/wp-content\/uploads\/2019\/03\/opensh-300x138.jpg\" alt=\"\" width=\"659\" height=\"303\" srcset=\"https:\/\/www.appservgrid.com\/paw93\/wp-content\/uploads\/2019\/03\/opensh-300x138.jpg 300w, https:\/\/www.appservgrid.com\/paw93\/wp-content\/uploads\/2019\/03\/opensh-768x352.jpg 768w, https:\/\/www.appservgrid.com\/paw93\/wp-content\/uploads\/2019\/03\/opensh-1024x470.jpg 1024w, https:\/\/www.appservgrid.com\/paw93\/wp-content\/uploads\/2019\/03\/opensh.jpg 1096w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/p>\n<p>In this tutorial we will install\u00a0<a href=\"https:\/\/www.openshift.com\/\">OpenShift<\/a>\u00a0in a container using a new tool called\u00a0<a href=\"https:\/\/github.com\/weaveworks\/footloose\">footloose<\/a>\u00a0by\u00a0<a href=\"https:\/\/github.com\/weaveworks\/\">Weaveworks<\/a>.<\/p>\n<blockquote><p>Footloose is a tool built by Weaveworks which builds and runs a container with systemd installed. It can be created in a similar way to a VM but without the overheads.<\/p><\/blockquote>\n<p>I wrote this tutorial because I wanted a light-weight environment for testing the\u00a0<a href=\"https:\/\/www.openfaas.com\/\">OpenFaaS project<\/a>\u00a0on OpenShift Origin 3.10. An alternative distribution for testing is\u00a0<a href=\"https:\/\/github.com\/minishift\/minishift\">Minishift<\/a>\u00a0which also allows you to run OpenShift locally, but in a much more heavy-weight VM.<\/p>\n<h2 id=\"installfootloose\">Install Footloose<\/h2>\n<p>You can use a Linux machine or MacOS host for this tutorial. ARM and Raspberry Pi are not supported.<\/p>\n<ul>\n<li>Install Footloose<\/li>\n<\/ul>\n<p>Follow the instructions on the official website:<\/p>\n<p><a href=\"https:\/\/github.com\/weaveworks\/footloose\">https:\/\/github.com\/weaveworks\/footloose<\/a><\/p>\n<ul>\n<li>Create a config<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">cluster:\r\n  name: cluster\r\n  privateKey: cluster-key\r\nmachines:\r\n- count: 1\r\n  spec:\r\n    image: quay.io\/footloose\/centos7:0.3.0\r\n    name: os%d\r\n    privileged: true\r\n    portMappings:\r\n    - containerPort: 22\r\n    - containerPort: 8443\r\n      hostPort: 8443\r\n    - containerPort: 53\r\n      hostPort: 53\r\n    - containerPort: 443\r\n      hostPort: 443\r\n    - containerPort: 80\r\n      hostPort: 80\r\n    volumes:\r\n    - type: volume\r\n      destination: \/var\/lib\/docker\r\n<\/code><\/pre>\n<p><em>footloose.yaml<\/em><\/p>\n<p>Note the additional ports 8443 and 53 used by OpenShift Origin and then 80 and 443 are bound for exposing your projects.<\/p>\n<p>If you already have services bound to 80\/443 then you can comment out these lines.<\/p>\n<ul>\n<li>Start the CentOS container<\/li>\n<\/ul>\n<pre><code>footloose create\r\n<\/code><\/pre>\n<ul>\n<li>Start a root shell<\/li>\n<\/ul>\n<pre><code>footloose ssh root@os0\r\n<\/code><\/pre>\n<h3 id=\"configuredocker\">Configure Docker<\/h3>\n<ul>\n<li>Install and start Docker<\/li>\n<\/ul>\n<pre><code>yum check-update\r\ncurl -fsSL https:\/\/get.docker.com\/ | sh\r\n<\/code><\/pre>\n<blockquote><p>Instructions from:\u00a0<a href=\"https:\/\/docs.docker.com\/install\/linux\/docker-ce\/centos\/\">docker.com<\/a><\/p><\/blockquote>\n<ul>\n<li>Add an insecure registry<\/li>\n<\/ul>\n<p>Find the subnet:<\/p>\n<pre><code># ifconfig eth0\r\neth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500\r\n        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255\r\n<\/code><\/pre>\n<ul>\n<li>Create\u00a0<code>\/etc\/docker\/daemon.json<\/code><\/li>\n<\/ul>\n<pre><code>mkdir -p \/etc\/docker\r\n\r\ncat &gt; \/etc\/docker\/daemon.json &lt;&lt;EOF\r\n{\r\n   \"insecure-registries\": [\r\n     \"172.17.0.0\/16\"\r\n   ]\r\n}\r\nEOF\r\n<\/code><\/pre>\n<ul>\n<li>Now enable \/ start Docker<\/li>\n<\/ul>\n<pre><code>systemctl daemon-reload \\\r\n &amp;&amp; systemctl enable docker \\\r\n &amp;&amp; systemctl start docker\r\n<\/code><\/pre>\n<h2 id=\"installopenshift\">Install OpenShift<\/h2>\n<ul>\n<li>Grab the OpenShift client tools<\/li>\n<\/ul>\n<p>Find the latest URL from:\u00a0<a href=\"https:\/\/www.okd.io\/download.html\">https:\/\/www.okd.io\/download.html<\/a><\/p>\n<pre><code>wget https:\/\/github.com\/openshift\/origin\/releases\/download\/v3.11.0\/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \\\r\n  &amp;&amp; tar -xvf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \\\r\n  &amp;&amp; rm -rf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \\\r\n  &amp;&amp; mv open* openshift\r\n<\/code><\/pre>\n<ul>\n<li>Make\u00a0<code>oc<\/code>\u00a0available via\u00a0<code>PATH<\/code><\/li>\n<\/ul>\n<pre><code>export PATH=$PATH:`pwd`\/openshift\r\n<\/code><\/pre>\n<ul>\n<li>Authenticate to the Docker hub<\/li>\n<\/ul>\n<pre><code>docker login\r\n<\/code><\/pre>\n<ul>\n<li>Install OpenShift<\/li>\n<\/ul>\n<pre><code>oc cluster up --skip-registry-check=true\r\n<\/code><\/pre>\n<p>This will take a few minutes<\/p>\n<p>If you see an error \/ timeout at\u00a0<code>run_self_hosted.go:181] Waiting for the kube-apiserver to be ready<\/code>then run the command again until it passes.<\/p>\n<p>When done you&#8217;ll see this output:<\/p>\n<pre><code>\r\nLogin to server ...\r\nCreating initial project \"myproject\" ...\r\n\r\nServer Information ...\r\nOpenShift server started.\r\n\r\nThe server is accessible via web console at:\r\n    https:\/\/127.0.0.1:8443\r\n\r\nYou are logged in as:\r\n    User:     developer\r\n    Password: &lt;any value&gt;\r\n\r\nTo login as administrator:\r\n    oc login -u system:admin\r\n<\/code><\/pre>\n<p>You can now install the\u00a0<code>oc<\/code>\u00a0tool on your host machine or access the portal through\u00a0<code>https:\/\/127.0.0.1:8443<\/code>\u00a0on the host.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.alexellis.io\/content\/images\/2019\/03\/portal.png\" alt=\"portal\" \/><\/p>\n<h2 id=\"testyouropenshiftcluster\">Test your OpenShift cluster<\/h2>\n<p>Let&#8217;s install\u00a0<a href=\"https:\/\/www.openfaas.com\/\">OpenFaaS<\/a>\u00a0which makes Serverless Functions Simple through the user of Docker images and Kubernetes. OpenShift is effectively a distribution of Kubernetes, so with some testing and tweaking everything should work almost out of the box.<\/p>\n<p>OpenFaaS supports microservices, functions, scale to zero, source to URL and much more. Today we&#8217;ll try out one of the sample functions from the Function Store to check when an SSL certificate will expire.<\/p>\n<ul>\n<li>Install OpenFaaS<\/li>\n<\/ul>\n<pre><code>oc login -u system:admin\r\n\r\noc adm new-project openfaas\r\noc adm new-project openfaas-fn\r\n\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/alertmanager-cfg.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/alertmanager-dep.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/alertmanager-svc.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/gateway-dep.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/gateway-svc.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/nats-dep.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/nats-svc.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/prometheus-cfg.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/prometheus-dep.yml\r\n\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/prometheus-rbac.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/prometheus-svc.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/queueworker-dep.yml\r\noc apply -f https:\/\/raw.githubusercontent.com\/openfaas\/faas-netes\/master\/yaml\/rbac.yml\r\n<\/code><\/pre>\n<p>Now let&#8217;s create a route for the gateway:<\/p>\n<pre><code>cat &gt; route.yaml &lt;&lt; EOF\r\napiVersion: route.openshift.io\/v1\r\nkind: Route\r\nmetadata:\r\n  name: openfaas\r\n  namespace: openfaas\r\nspec:\r\n  host: footloose-gateway.com\r\n  to:\r\n    kind: Service\r\n    name: gateway\r\n    weight: 100\r\n  wildcardPolicy: None\r\n  tls:\r\n    termination: edge\r\nEOF\r\n\r\noc apply -f route.yaml\r\n<\/code><\/pre>\n<p>Add an entry to \/etc\/hosts<\/p>\n<pre><code>127.0.0.1 footloose-gateway.com\r\n<\/code><\/pre>\n<p>Access the OpenFaaS UI at:\u00a0<a href=\"https:\/\/footloose-gateway.com\/\">https:\/\/footloose-gateway.com\/<\/a><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.alexellis.io\/content\/images\/2019\/03\/portal-of.png\" alt=\"portal-of\" \/><\/p>\n<ul>\n<li>Install the CLI and deploy a function<\/li>\n<\/ul>\n<pre><code>export OPENFAAS_URL=https:\/\/footloose-gateway.com\r\n\r\nfaas-cli store deploy --tls-no-verify certinfo\r\n\r\nDeployed. 202 Accepted.\r\nURL: https:\/\/footloose-gateway.com\/function\/certinfo\r\n<\/code><\/pre>\n<p>Once the function shows Ready in the OpenFaaS UI invoke it:<\/p>\n<pre><code>export OPENFAAS_URL=https:\/\/footloose-gateway.com\r\n\r\necho -n www.openfaas.com | faas-cli invoke --tls-no-verify certinfo\r\n\r\nHost 185.199.110.153\r\nPort 443\r\nIssuer Let's Encrypt Authority X3\r\nCommonName www.openfaas.com\r\nNotBefore 2019-03-21 12:21:00 +0000 UTC\r\nNotAfter 2019-06-19 12:21:00 +0000 UTC\r\nNotAfterUnix 1560946860\r\nSANs [www.openfaas.com]\r\nTimeRemaining 2 months from now\r\n<\/code><\/pre>\n<p>You can grant your &#8220;developer&#8221; user access to see the openfaas \/ openfaas-fn projects through the following command:<\/p>\n<pre><code>oc adm policy add-cluster-role-to-user  cluster-reader developer\r\n<\/code><\/pre>\n<p>Here we are inspecting the Pod created by OpenFaaS for the certinfo function:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.alexellis.io\/content\/images\/2019\/03\/info-certinfo.png\" alt=\"info-certinfo\" \/><\/p>\n<h3 id=\"teardown\">Tear-down<\/h3>\n<p>If you want to remove the OpenShift cluster you can run:\u00a0<code>footloose delete<\/code>\u00a0in the directory on the host.<\/p>\n<h2 id=\"wrappingup\">Wrapping up<\/h2>\n<p>We&#8217;ve installed a functional OpenShift Origin cluster into a container and run it on a machine where the only requirement is to have Docker present. It should have taken us around 5 minutes. Once complete we deployed a production-grade application and were able to test workloads.<\/p>\n<p>Whether you use\u00a0<a href=\"https:\/\/github.com\/minishift\/minishift\">minishift<\/a>,\u00a0<a href=\"https:\/\/medium.com\/@lizrice\/a-single-node-openshift-3-10-cluster-aaa63e2deed7\">Vagrant &#8211; tutorial by Liz Rice<\/a>\u00a0or footloose using this tutorial, testing your application on OpenShift hasn&#8217;t been easier than this.<\/p>\n<p>I want to give acknowledgements to\u00a0<a href=\"https:\/\/twitter.com\/dale_bingham\">Dale Bingham<\/a>\u00a0from Spalding Consulting and Michael Schendel from DESI for helping test and port OpenFaaS to OpenShift. This mainly involved a\u00a0<a href=\"https:\/\/github.com\/openfaas\/faas-netes\/pull\/394\">small patch<\/a>\u00a0to add an emptyDir volume for Prometheus.<\/p>\n<h3 id=\"whatsnext\">What&#8217;s next?<\/h3>\n<p>I&#8217;ll continue to work with Dale, Michael to create a\u00a0<a href=\"https:\/\/docs.openfaas.com\/deployment\/openshift\/\">dedicated documentation page<\/a>\u00a0for installing OpenShift on OpenFaaS. We&#8217;ll also be testing the\u00a0<a href=\"https:\/\/github.com\/openfaas\/faas-netes\/tree\/master\/chart\/openfaas\">helm chart<\/a>and all other OpenFaaS features on OpenShift Origin such as scale-to-zero and if there is interest &#8211; OpenFaaS Cloud.<\/p>\n<blockquote><p>Note: when using the helm chart authentication is enabled by default &#8211; just run\u00a0<code>faas-cli login<\/code>.<\/p><\/blockquote>\n<p><a href=\"https:\/\/github.com\/dlespiau\">Damien<\/a>\u00a0the author of Footloose is looking into how the Footloose tool could be used with a script or provisioning file to carry out all the steps of this tutorial in one single step. If you&#8217;d like to help him checkout his project at:\u00a0<a href=\"https:\/\/github.com\/weaveworks\/footloose\">https:\/\/github.com\/weaveworks\/footloose<\/a><\/p>\n<p>If you&#8217;re an OpenShift user, expert or just want to help out. Please\u00a0<a href=\"https:\/\/docs.openfaas.com\/community\">join us on Slack<\/a>.<\/p>\n<p><a href=\"https:\/\/blog.alexellis.io\/openshift-in-a-footloose-container\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will install\u00a0OpenShift\u00a0in a container using a new tool called\u00a0footloose\u00a0by\u00a0Weaveworks. Footloose is a tool built by Weaveworks which builds and runs a container with systemd installed. It can be created in a similar way to a VM but without the overheads. I wrote this tutorial because I wanted a light-weight environment for &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/03\/27\/install-openshift-in-a-container-with-weave-footloose\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install OpenShift in a container with Weave Footloose&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1525","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=1525"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1525\/revisions"}],"predecessor-version":[{"id":1592,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1525\/revisions\/1592"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=1525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=1525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}