-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
305 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,7 @@ build: | |
build-operator-image: | ||
docker build --no-cache -f Dockerfile-operator -t ${operator-image} . | ||
|
||
build-all-images: | ||
docker build --no-cache -f Dockerfile-operator -t ${operator-image} . | ||
|
||
test-spawn: | ||
test: | ||
MIX_ENV=test elixir --name [email protected] -S mix test | ||
|
||
test-operator: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
flame_example-*.tar | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: flame-parent-example | ||
namespace: default | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: flame-parent-example | ||
template: | ||
metadata: | ||
annotations: | ||
flame.org/enabled: "true" | ||
flame.org/dist-auto-config: "true" | ||
flame.org/otp-app: "flame_example" | ||
flame.org/pool-config-ref: "custom-pool-example" | ||
spec: | ||
containers: | ||
- image: eigr/flame-parent-example:1.1.1 | ||
name: flame-parent-example | ||
resources: | ||
limits: | ||
cpu: 200m | ||
memory: 200Mi | ||
requests: | ||
cpu: 200m | ||
memory: 200Mi | ||
volumeMounts: | ||
- mountPath: /app/.cache/bakeware/ | ||
name: bakeware-cache | ||
volumes: | ||
- name: bakeware-cache | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
apiVersion: flame.org/v1 | ||
kind: FlamePool | ||
metadata: | ||
name: custom-pool-example | ||
namespace: default | ||
spec: | ||
podTemplate: | ||
spec: | ||
containers: | ||
- env: | ||
- name: MY_VAR | ||
value: "my-value" | ||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 256Mi | ||
requests: | ||
cpu: 200m | ||
memory: 2Gi | ||
volumeMounts: | ||
- mountPath: /app/.cache/bakeware/ | ||
name: bakeware-cache | ||
volumes: | ||
- name: bakeware-cache | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM elixir:1.14-alpine as builder | ||
|
||
ENV MIX_ENV=prod | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add --no-cache --update git build-base ca-certificates zstd gcc pkgconfig openssl-dev | ||
|
||
RUN mkdir config | ||
COPY config/ ./config | ||
COPY lib/ ./lib | ||
COPY priv/ ./priv | ||
COPY mix.exs . | ||
COPY mix.lock . | ||
|
||
RUN mix local.rebar --force \ | ||
&& mix local.hex --force \ | ||
&& mix deps.get \ | ||
&& mix release.init | ||
|
||
ENV RELEASE_DISTRIBUTION="name" | ||
|
||
# Overriden at runtime | ||
ENV POD_IP="127.0.0.1" | ||
|
||
# This will be the basename of node | ||
ENV RELEASE_NAME="flame_example" | ||
|
||
# This will be the full nodename | ||
ENV RELEASE_NODE="${RELEASE_NAME}@${POD_IP}" | ||
|
||
RUN echo "-setcookie ${NODE_COOKIE}" >> ./rel/vm.args.eex | ||
|
||
RUN mix deps.get \ | ||
&& mix release flame_example | ||
|
||
# ---- Application Stage ---- | ||
FROM alpine:3.17.3 | ||
|
||
RUN apk add --no-cache --update zstd ncurses-libs libstdc++ libgcc libcrypto1.1 | ||
|
||
WORKDIR /app | ||
RUN chown nobody /app | ||
|
||
# Set runner ENV | ||
ENV MIX_ENV=prod | ||
ENV HOME=/app | ||
|
||
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/bakeware/ ./ | ||
|
||
RUN mkdir -p /app/.cache/bakeware/ && chmod 777 /app/.cache/bakeware/ | ||
RUN touch /.erlang.cookie && chmod 777 /.erlang.cookie | ||
RUN touch /app/.erlang.cookie && chmod 777 /app/.erlang.cookie | ||
|
||
USER nobody | ||
|
||
ENTRYPOINT [ "./flame_example", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version=1.1.1 | ||
registry=eigr | ||
|
||
image=${registry}/flame-parent-example:${version} | ||
|
||
.PHONY: all | ||
|
||
all: clean-all build build-image create-kind-cluster create-k8s-namespace load-kind-images | ||
|
||
clean: | ||
mix deps.clean --all | ||
|
||
clean-all: | ||
mix deps.clean --all && kind delete cluster --name flame-cluster | ||
|
||
build: | ||
mix deps.get && mix compile | ||
|
||
build-image: | ||
docker build --no-cache -f Dockerfile -t ${image} . | ||
|
||
push-all-images: | ||
docker push ${image} | ||
|
||
create-kind-cluster: | ||
kind create cluster -v 1 --name flame-cluster --config kind-cluster.yaml | ||
kubectl cluster-info --context kind-flame-cluster | ||
|
||
load-kind-images: | ||
kind load docker-image ${image} --name flame-cluster | ||
|
||
create-k8s-namespace: | ||
kubectl create ns flame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# FlameExample | ||
|
||
**TODO: Add description** | ||
|
||
## Installation | ||
|
||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed | ||
by adding `flame_example` to your list of dependencies in `mix.exs`: | ||
|
||
```elixir | ||
def deps do | ||
[ | ||
{:flame_example, "~> 0.1.0"} | ||
] | ||
end | ||
``` | ||
|
||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) | ||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can | ||
be found at <https://hexdocs.pm/flame_example>. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Config | ||
|
||
config :logger, :console, | ||
format: "$date $time [$node]:[$metadata]:[$level]:$message\n", | ||
metadata: [:pid, :span_id, :trace_id] | ||
|
||
if config_env() == :prod do | ||
config :flame, :backend, FLAME.K8sBackend | ||
config :flame, FLAME.K8sBackend, log: :debug | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 31436 | ||
hostPort: 31436 | ||
listenAddress: "127.0.0.1" | ||
- containerPort: 31437 | ||
hostPort: 31437 | ||
listenAddress: "127.0.0.1" | ||
kubeadmConfigPatches: | ||
- | | ||
kind: ClusterConfiguration | ||
apiServer: | ||
extraArgs: | ||
enable-admission-plugins: MutatingAdmissionWebhook,ValidatingAdmissionWebhook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule FlameExample do | ||
@moduledoc """ | ||
Documentation for `FlameExample`. | ||
""" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule FlameExample.Application do | ||
@moduledoc false | ||
|
||
use Application | ||
|
||
@impl true | ||
def start(_type, _args) do | ||
children = [] | ||
|
||
opts = [strategy: :one_for_one, name: FlameExample.Supervisor] | ||
Supervisor.start_link(children, opts) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule FlameExample.MixProject do | ||
use Mix.Project | ||
|
||
@app :flame_example | ||
@version "0.1.0" | ||
|
||
def project do | ||
[ | ||
app: @app, | ||
version: @version, | ||
elixir: "~> 1.14", | ||
start_permanent: Mix.env() == :prod, | ||
deps: deps(), | ||
releases: releases() | ||
] | ||
end | ||
|
||
def application do | ||
[ | ||
extra_applications: [:logger], | ||
mod: {FlameExample.Application, []} | ||
] | ||
end | ||
|
||
defp deps do | ||
[ | ||
{:bakeware, ">= 0.0.0", runtime: false}, | ||
{:bandit, "~> 1.1"}, | ||
{:flame, "~> 0.1.6"}, | ||
{:flame_k8s, "~> 0.1.0"} | ||
] | ||
end | ||
|
||
defp releases do | ||
[ | ||
flame_example: [ | ||
include_executables_for: [:unix], | ||
applications: [flame_example: :permanent], | ||
steps: [ | ||
:assemble, | ||
&Bakeware.assemble/1 | ||
], | ||
bakeware: [compression_level: 19] | ||
] | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule FlameExampleTest do | ||
use ExUnit.Case | ||
doctest FlameExample | ||
|
||
test "greets the world" do | ||
assert FlameExample.hello() == :world | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters