Browse Source

add cdk8s-guestbook dir

pull/51/head
Max Brenner 5 years ago
committed by Max Brenner
parent
commit
75256a34bf
  1. 17
      cdk8s-guestbook/Dockerfile
  2. 10
      cdk8s-guestbook/Pipfile
  3. 4
      cdk8s-guestbook/cdk8s.yaml
  4. 19
      cdk8s-guestbook/config.yml
  5. 36
      cdk8s-guestbook/main.py

17
cdk8s-guestbook/Dockerfile

@ -0,0 +1,17 @@
FROM argoproj/argocd:latest
USER root
RUN apt-get update && \
apt-get install -y \
curl \
python3-pip && \
apt-get clean && \
pip3 install pipenv
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn
RUN yarn global add npm cdk8s-cli
USER argocd

10
cdk8s-guestbook/Pipfile

@ -0,0 +1,10 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[requires]
python_version = "3.7"
[packages]
cdk8s = "*"

4
cdk8s-guestbook/cdk8s.yaml

@ -0,0 +1,4 @@
language: python
app: pipenv run ./main.py
imports:
- k8s

19
cdk8s-guestbook/config.yml

@ -0,0 +1,19 @@
apiVersion: v1
data:
configManagementPlugins: |
- name: cdk8s
init:
command: ["bash"]
args: ["-c", "pipenv install && cdk8s import -l python && cdk8s synth"]
generate:
command: ["bash"]
args: ["-c", "cat dist/*"]
kind: ConfigMap
metadata:
annotations:
labels:
app.kubernetes.io/name: argocd-cm
app.kubernetes.io/part-of: argocd
name: argocd-cm
namespace: argocd
selfLink: /api/v1/namespaces/argocd/configmaps/argocd-cm

36
cdk8s-guestbook/main.py

@ -0,0 +1,36 @@
#!/usr/bin/env python
from constructs import Construct
from cdk8s import App, Chart
from imports import k8s
class MyChart(Chart):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
label = {"app": "guestbook-ui"}
k8s.Service(self, 'service',
spec=k8s.ServiceSpec(
type='LoadBalancer',
ports=[k8s.ServicePort(port=80, target_port=k8s.IntOrString.from_number(80))],
selector=label))
k8s.Deployment(self, 'deployment',
spec=k8s.DeploymentSpec(
replicas=1,
selector=k8s.LabelSelector(match_labels=label),
template=k8s.PodTemplateSpec(
metadata=k8s.ObjectMeta(labels=label),
spec=k8s.PodSpec(containers=[
k8s.Container(
name='guestbook-ui',
image='gcr.io/heptio-images/ks-guestbook-demo:0.2',
ports=[k8s.ContainerPort(container_port=80)])]))))
app = App()
MyChart(app, "cdk8s-guestbook")
app.synth()
Loading…
Cancel
Save