Git Product home page Git Product logo

porter-moon-demo's Introduction

porter-moon-demo

Overview

This is a simple POC of authoring a Porter bundle with MoonScript.

The deploys an instance of HackMD (CodiMD) using the Helm mixin, backed by an Azure Database for PostgreSQL created using the Azure mixin.

porter.moon

The file porter.moon in this repo contains the bundle definition:

-- porter.moon ๐ŸŒœ๐Ÿ’ซ

import MyCloudApp from require("lib/mycloudapp")

name = "my-cloud-app"
version = "0.1.3"
description = "takes us up to the cloud, the moon even"

-- General configuration. Modify for your own registry. This pushes the
-- invocation image to Docker Hub account/org based on the USER env var.
-- Note: the "my-cloud-app" repo must first be created via Docker Hub UI.
config = {
    meta: {:name, :version, :description}
    registry: {
        host: "docker.io",
        repo: os.getenv("USER").."/"..name
        tag: version.."-develop"
    }
}

export bundle = MyCloudApp(config).bundle

The MyCloudApp class (defined here) defines the all the different mixins, credentials, and actions for the bundle.

This is the resulting porter.yaml after conversion from MoonScript/Lua:

credentials:
- name: kubeconfig
  path: /root/.kube/config
description: takes us up to the cloud, the moon even
install:
- azure:
    description: Install azure postgres db "my-cloud-app-hackmd" (in eastus)
    name: my-cloud-app-hackmd
    parameters:
      administratorLogin: myadminuser
      administratorLoginPassword: myAdminPass123!
      databaseName: hackmd
      location: eastus
      serverName: my-cloud-app-hackmd
    resourceGroup: my-cloud-app-hackmd
    type: postgres
- helm:
    chart: stable/hackmd
    description: Install helm release "my-cloud-app-hackmd" (stable/hackmd 1.1.0)
    name: my-cloud-app-hackmd
    replace: true
    set:
      persistence.enabled: false
      postgresql.install: false
      postgresql.postgresDatabase: hackmd
      postgresql.postgresHost: my-cloud-app-hackmd.postgres.database.azure.com
      postgresql.postgresPassword: myAdminPass123!
      postgresql.postgresUser: [email protected]
      replicaCount: 2
      sessionSecret: abcde12345
    version: 1.1.0
invocationImage: docker.io/jdolitsky/my-cloud-app:0.1.3-develop
mixins:
- azure
- helm
name: my-cloud-app
uninstall:
- helm:
    description: Uninstall helm release "my-cloud-app-hackmd" (stable/hackmd 1.1.0)
    purge: true
    releases:
    - my-cloud-app-hackmd
upgrade:
- helm:
    chart: stable/hackmd
    description: Upgrade helm release "my-cloud-app-hackmd" (stable/hackmd 1.1.0)
    name: my-cloud-app-hackmd
    set:
      persistence.enabled: false
      postgresql.install: false
      postgresql.postgresDatabase: hackmd
      postgresql.postgresHost: my-cloud-app-hackmd.postgres.database.azure.com
      postgresql.postgresPassword: myAdminPass123!
      postgresql.postgresUser: [email protected]
      replicaCount: 2
      sessionSecret: abcde12345
    version: 1.1.0
version: 0.1.3

How to use

The following commands can be run in the root of this repo after installing moopo (a space-age Porter pre-processor that converts porter.moon into porter.yaml).

Install bundle

$ moopo run --action=install
[moopo] Converting porter.moon to porter.lua... Done.
[moopo] Converting porter.lua to porter.yaml... Done.
executing porter install configuration from porter.yaml
Install azure postgres db "my-cloud-app-hackmd" (in eastus)
Starting deployment operations...
...

Upgrade bundle

$ moopo run --action=upgrade
[moopo] Converting porter.moon to porter.lua... Done.
[moopo] Converting porter.lua to porter.yaml... Done.
executing porter upgrade configuration from porter.yaml
Upgrade helm release "my-cloud-app-hackmd" (stable/hackmd 1.1.0)
...

Uninstall bundle

$ moopo run --action=uninstall
[moopo] Converting porter.moon to porter.lua... Done.
[moopo] Converting porter.lua to porter.yaml... Done.
executing porter uninstall configuration from porter.yaml
Uninstall helm release "my-cloud-app-hackmd" (stable/hackmd 1.1.0)
...

Build and push bundle

Run this in an environment that is allowed to push the invocation image.

$ moopo build
[moopo] Converting porter.moon to porter.lua... Done.
[moopo] Converting porter.lua to porter.yaml... Done.
Copying dependencies ===>
Copying mixins ===>
...

porter-moon-demo's People

Contributors

jdolitsky avatar

Stargazers

 avatar  avatar  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.