Creating a Run Platform

A run platform is a special environment that deploys the definitions of environments, its a Maven project that produces a Docker image from a set of templates.

The result of creating a RUN Platform is a docker image with everything you need to seed a cluster and start deploying environments.

The RUN platform in pictures

This document describes how to create the image for the inner practiv-shared-build-run-platform box in the diagram, which is a more detailed view of what happens after a PR is approved and merged.

In this diagram practiv-shared-build-run-platform and forge-build are represented both as Namespaces and the containers that were used to build them.

These are the files you need

These are the files you need for a run platform environment

pom.xml
Jenkinsfile
src
└── main
    └── kubernetes
        └── forge-build
            └── canary.yaml
environment.properties

Declare the project

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.practiv.stable.anvil</groupId>
    <artifactId>anvil-parent</artifactId>
    <version>#{anvil-parent.version}</version>
  </parent>

  <groupId>io.practiv.stable.practiv-shared-build</groupId>
  <artifactId>practiv-shared-build-run-platform</artifactId>
  <version>1.999-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>${project.artifactId}</name>
  <description>Run Platform meta environment for Practiv</description>

  <properties>
    <properties>
    <environmentDomain>practiv-shared-build.forge.practiv.io</environmentDomain>
    <environmentColour>${tile-colour.gke}</environmentColour>
    <clusterName>practiv-shared-build</clusterName>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>io.repaint.maven</groupId>
        <artifactId>tiles-maven-plugin</artifactId>
        <version>2.34</version>
        <configuration>
          <tiles>
            <tile>io.practiv.stable.anvil:anvil-tile-build:[1,2)</tile>
            <tile>io.practiv.stable.anvil:anvil-tile-run:[1,2)</tile>
            <tile>io.practiv.stable.chalk:chalk-run-platform-gke:[18,19)</tile> 
          </tiles>
        </configuration>
      </plugin>

      <plugin>
        <groupId>net.stickycode.plugins</groupId>
        <artifactId>shifty-maven-plugin</artifactId>
        <version>1.18</version>
        <executions>
          <execution>
            <id>fetch-applications</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>fetch</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/resources/kubernetes</outputDirectory>
              <unpack>true</unpack>
              <artifacts>
                <artifact>io.practiv.stable.forge:forge-build:[1,2]:run-platform:zip</artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>

Jenkinsfile

mavenBuild()

Set up the environment properties

The environment properties has the placeholders for all the the Kubernetes templates, the simplest way to find what’s missing is to run the build and let it fail

branchout-maven cv

snippet branchout-maven cv

UNRESOLVED CONFIGURATION FOUND in /charts/rocket-build/practiv-run-oauth-proxy/config.yaml
28-      ".build.acme.practiv.io"
29-    ]
30-
31-    http_address = "0.0.0.0:4180"
32-
33:    github_org="${githubOauthOrganisation}"

Then put the values in the environment properties file

environment.properties

githubOauthOrganisation=Practiv
githubOauthTeams=development,operators
githubUrl=https://git.practiv.io

Build it

Building the project will prompt for the missing Secrets and Configurations

mvn -f pom.xml -s /home/malt/branchout/acme/maven/settings.xml --no-transfer-progress clean verifyy
[INFO] Scanning for projects...
[INFO] --- tiles-maven-plugin: Injecting 14 tiles as intermediary parent artifacts for io.practiv.acme.stable.rocket:rocket-build...
...