From b40c6bde5c6c22bcef953a5782d267edb647cf11 Mon Sep 17 00:00:00 2001 From: marcel-dempers Date: Fri, 23 Oct 2020 21:04:56 +1100 Subject: [PATCH] waypoint wip --- .gitignore | 5 +- hashicorp/waypoint/README.md | 58 ++++++++++++++++++++++ hashicorp/waypoint/python/dockerfile | 12 +++++ hashicorp/waypoint/python/requirements.txt | 1 + hashicorp/waypoint/python/server.py | 6 +++ hashicorp/waypoint/python/waypoint.hcl | 31 ++++++++++++ 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 hashicorp/waypoint/README.md create mode 100644 hashicorp/waypoint/python/dockerfile create mode 100644 hashicorp/waypoint/python/requirements.txt create mode 100644 hashicorp/waypoint/python/server.py create mode 100644 hashicorp/waypoint/python/waypoint.hcl diff --git a/.gitignore b/.gitignore index 69b85ccc4..2d9588296 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ __pycache__/ .terraform *.tfstate *.tfstate.* -security/letsencrypt/introduction/certs/** \ No newline at end of file +security/letsencrypt/introduction/certs/** + +hashicorp/waypoint/*/data.db* +hashicorp/waypoint/*/.waypoint \ No newline at end of file diff --git a/hashicorp/waypoint/README.md b/hashicorp/waypoint/README.md new file mode 100644 index 000000000..038fb39fe --- /dev/null +++ b/hashicorp/waypoint/README.md @@ -0,0 +1,58 @@ +# Introduction to Waypoint + +I will do the following:
+ +* Run a local Kubernetes cluster with [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) +* Run a container to extract the windows `waypoint` binary + move it to $PATH + + +## We need a Kubernetes cluster + +Lets create a Kubernetes cluster to play with using [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) + +``` +kind create cluster --name waypoint --image kindest/node:v1.19.1 +``` + +## Get the Waypoint binary for Windows + +
+Feel free to follow the official install guide using the [docs](https://learn.hashicorp.com/tutorials/waypoint/get-started-install)
+ +
+ +Use a container to download and extract the binary: + +``` +docker run -it --rm -v ${PWD}:/work -w /work alpine sh -c 'apk add --no-cache curl unzip && curl -LO https://releases.hashicorp.com/waypoint/0.1.3/waypoint_0.1.3_windows_amd64.zip && unzip waypoint_0.1.3_windows_amd64.zip && rm waypoint_0.1.3_windows_amd64.zip' + +``` + +I've setup my Windows $PATH environment to point to a folder `C:\kubectl\` + +``` +mv waypoint.exe C:\kubectl\waypoint.exe + +#open new powershell terminal + +waypoint --help +``` + +
+ +## Install Waypoint server + +``` +kubectl port-forward svc/waypoint 9701:9701 +waypoint install --platform=kubernetes -accept-tos +``` + + +## Waypoint Kubernetes + Python example + +``` +cd hashicorp/waypoint/python/ + +waypoint init +waypoint up +``` \ No newline at end of file diff --git a/hashicorp/waypoint/python/dockerfile b/hashicorp/waypoint/python/dockerfile new file mode 100644 index 000000000..814953809 --- /dev/null +++ b/hashicorp/waypoint/python/dockerfile @@ -0,0 +1,12 @@ +FROM python:3.7.3-alpine3.9 as base + +RUN mkdir /work/ +WORKDIR /work/ + +COPY requirements.txt /work/requirements.txt +RUN pip install -r requirements.txt + +COPY server.py /work/server.py + +ENV FLASK_APP=server.py +CMD flask run -h 0.0.0.0 -p 5000 diff --git a/hashicorp/waypoint/python/requirements.txt b/hashicorp/waypoint/python/requirements.txt new file mode 100644 index 000000000..9614ae3bd --- /dev/null +++ b/hashicorp/waypoint/python/requirements.txt @@ -0,0 +1 @@ +Flask == 1.0.3 \ No newline at end of file diff --git a/hashicorp/waypoint/python/server.py b/hashicorp/waypoint/python/server.py new file mode 100644 index 000000000..6c8be8237 --- /dev/null +++ b/hashicorp/waypoint/python/server.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello World!" \ No newline at end of file diff --git a/hashicorp/waypoint/python/waypoint.hcl b/hashicorp/waypoint/python/waypoint.hcl new file mode 100644 index 000000000..17543eb5f --- /dev/null +++ b/hashicorp/waypoint/python/waypoint.hcl @@ -0,0 +1,31 @@ +project = "example-nodejs" + +app "example-nodejs" { + labels = { + "service" = "example-nodejs", + "env" = "dev" + } + + build { + use "pack" {} + registry { + use "docker" { + image = "aimvector/waypoint-python-example" + tag = "1" + local = false + } + } + } + + deploy { + use "kubernetes" { + probe_path = "/" + } + } + + release { + use "kubernetes" { + port = 5000 + } + } +} \ No newline at end of file