Max Brenner
5 years ago
committed by
Max Brenner
5 changed files with 86 additions and 0 deletions
@ -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 |
@ -0,0 +1,10 @@ |
|||||
|
[[source]] |
||||
|
name = "pypi" |
||||
|
url = "https://pypi.org/simple" |
||||
|
verify_ssl = true |
||||
|
|
||||
|
[requires] |
||||
|
python_version = "3.7" |
||||
|
|
||||
|
[packages] |
||||
|
cdk8s = "*" |
@ -0,0 +1,4 @@ |
|||||
|
language: python |
||||
|
app: pipenv run ./main.py |
||||
|
imports: |
||||
|
- k8s |
@ -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 |
@ -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…
Reference in new issue