Coder Social home page Coder Social logo

minimal_kubernetes_on_oc's Introduction

Minimal kubernetes deployment on Openshift 4

Trying to document an almost pure kubernetes deployment without openshift flavor, except Route.

Prerequisites

Deploy the demo

  1. copy the file .env-example to .env
  2. edit .env with the proper values for your context
  3. from a bash terminal at project root (in the same folder as the file named load_env.sh) run:
source ./load_env.sh   
ci/all.sh  

Explanation

Things to know:

  • Kubernetes is stateless. You should not run a database in a pod because data will be lost each time the pod restarts.
  • A pod is the littlest element in Kubernetes and is a concept close to a docker container.
  • Openshift runs pod without root privileges. You will need to tweak your docker image accordingly. see chmod.
  • Deployment defines how to run a pod (name, image, environments, ...).
  • Service allows 2 sets of pods to communicate and is scoped by the namespace.
  • Route is an Openshift plugins that allows to access a Service from the outside with an URL using an internal DNS feature.
  • You need to tag your image with the name of the Openshift registry. The full name is expected in the Deployment.

Kubernetes on Openshift

The command source ./load_env.sh creates environment variables that allow to fill the blank in the files from the folder dockerfiles/, kubernetes/ and ci/. This command will ask for your openshift password because we don't want to keep this password in a file.
Linux shell scripts can substitute environment variable automatically. kubectl don't. For this reason, we use envsubst that allows to replace the variables in kubernetes files with the actual values. This allows to use git to keep the configuration without the sensitive data. The file .env contains the sensitive data and is not versioned.

ci/all.sh runs those scripts in sequence:

  • build.sh: build all dockerfiles from the folder dockerfiles/, tag them with the proper name.
  • push.sh: push the image into the openshift registry.
  • deploy.sh: deploy all the configuration from the folder kubernetes/ on Openshift and restart existing Deployment.

Troubleshooting

  • Check the log of the pod that crash.
  • Make sure that the name of the image contains the fullname: registry/namespace/image:tag
  • If your pod crashes with a permission denied on a file/folder, run the command chmod -R ugo+rwx /your/folder in the dockerfile.

minimal_kubernetes_on_oc's People

Contributors

pylanglois avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.