Skip to content

Instantly share code, notes, and snippets.

@larsks

larsks/openshift-notes.md

Last active Jun 3, 2019
Embed
What would you like to do?
Some openshift stuff

A pod is the basic building block of OpenShift applications. A pod can contain one or more containers along with other information, like environment variables, volumes, and more. If you're familiar with docker-compose, a pod is largely equivalent to a docker-compose.yml file.

A simple pod to start up a database service might look like this:

---
apiVersion: v1
kind: Pod
metadata:
  name: mariadb
spec:
  containers:
    - name: mariadb
      image: mariadb:10-bionic
      imagePullPolicy: IfNotPresent
      env:
        - name: MYSQL_ROOT_PASSWORD
          value: root_secret
      ports:
        - containerPort: 3306
          protocol: TCP
      restartPolicy: Always

In practice, your deployments will probably be substantially more complex. Some changes we would want to make:

  • We would want to create a service to act as a front-end for Mariadb. This would allow us to associate a with the service in order to provide external access to the database.

  • We would probably want to mount a volume on /var/lib/mysql so that our data persists outside of the container filesystem.

  • We probably want to use OpenShift secrets to provide the value of MYSQL_ROOT_PASSWORD.


A deployment is a higher-level construct that includes rules for creating multiple replicas of a service (useful if you have an application that can scale out horizontally).


A template (such as your example from earlier) is an even higher-level construct for describing "a set of objects that can be parameterized and processed to produce a list of objects (secrets, services, pods, etc) for creation by OpenShift".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment