-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
86 additions
and
34 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ jobs: | |
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- uses: AbsaOSS/[email protected] | ||
id: k3d-cluster-1 | ||
with: | ||
|
@@ -34,6 +35,14 @@ jobs: | |
echo | ||
kubectl cluster-info | ||
- name: Nodes | ||
run: | | ||
docker ps -a | ||
kubectl get nodes -o wide | ||
- name: Network | ||
run: docker network inspect k3d-action-bridge-network | ||
|
||
- name: Install CDK8s-cli | ||
run: npm install -g cdk8s-cli | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
node_modules | ||
dist/ | ||
imports/ | ||
|
||
# Generated | ||
dist/* |
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 |
---|---|---|
@@ -1,25 +1,37 @@ | ||
MAKEFLAGS += --silent | ||
|
||
.PHONY: up down deploy status test | ||
.PHONY: up import synth deploy status test clean | ||
|
||
all: up import synth deploy status test | ||
echo "Doing all" | ||
|
||
up: | ||
which cdk8s || scripts/install.sh | ||
which cdk8s || npm install -g cdk8s-cli | ||
k3d cluster ls k3s-default || k3d cluster create --config k3d.yaml | ||
kubectl cluster-info | ||
|
||
down: | ||
echo -n "Are you sure? (ctrl+C to abort) " | ||
read _ | ||
k3d cluster stop k3s-default | ||
k3d cluster delete k3s-default | ||
import: | ||
pipenv install | ||
cdk8s import --language python | ||
|
||
deploy: | ||
synth: ## Create k8s manifest | ||
cdk8s synth | ||
|
||
deploy: | ||
kubectl apply -f ./dist/hello.k8s.yaml | ||
|
||
status: | ||
kubectl get svc,po | ||
kubectl get svc,po -o wide | ||
|
||
test: | ||
[ -f ./test/test.sh ] && ./test/test.sh | ||
|
||
clean: | ||
echo -n "Are you sure? (Press Enter to continue or Ctrl+C to abort) " | ||
read _ | ||
k3d cluster stop k3s-default | ||
k3d cluster delete k3s-default | ||
pipenv clean | ||
rm -rf ./dist ./imports | ||
|
||
-include include.mk |
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
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
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
#!/usr/bin/env python3 | ||
from constructs import Construct, Node | ||
|
||
from imports import k8s | ||
|
||
class WebService(Construct): | ||
|
||
def __init__(self, scope: Construct, id: str, *, image: str, replicas=1, port=80, containerPort=8080, **kwargs): | ||
super().__init__(scope, id) | ||
|
||
label = {"app": Node.of(self).id} | ||
|
||
k8s.KubeService(self, "service", | ||
spec=k8s.ServiceSpec( | ||
type="LoadBalancer", | ||
ports=[k8s.ServicePort(port=port, target_port=k8s.IntOrString.from_number(containerPort))], | ||
selector=label)) | ||
|
||
k8s.KubeDeployment(self, "deployment", | ||
spec=k8s.DeploymentSpec( | ||
replicas=replicas, | ||
selector=k8s.LabelSelector(match_labels=label), | ||
template=k8s.PodTemplateSpec( | ||
metadata=k8s.ObjectMeta(labels=label), | ||
spec=k8s.PodSpec(containers=[ | ||
k8s.Container( | ||
name="web", | ||
image=image, | ||
ports=[k8s.ContainerPort(container_port=containerPort)])])))) |