This commit is contained in:
nora 2024-07-06 22:35:11 +02:00
commit bce268cceb
13 changed files with 672 additions and 0 deletions

View file

@ -0,0 +1,45 @@
let
trivialWebService = { name, selectorLabel, port, extraPodLabels ? { } }:
[
{
apiVersion = "apps/v1";
kind = "Deployment";
metadata = {
inherit name;
};
spec = {
selector.matchLabels = selectorLabel;
replicas = 2;
template = {
metadata.labels = selectorLabel // extraPodLabels;
spec.containters = [
{
inherit name;
image = "nginx";
ports = [{ containerPort = port; }];
}
];
};
};
}
{
apiVersion = "apps/v1";
kind = "Service";
metadata = {
inherit name;
labels = selectorLabel;
};
spec = {
ports = { port = 80; protocol = "TCP"; };
selector = selectorLabel;
};
}
]
;
in
trivialWebService {
name = "my-nginx";
selectorLabel = { run = "my-nginx"; };
port = 80;
extraPodLabels = { someOther = "label"; };
}

View file

@ -0,0 +1,33 @@
[
{
apiVersion = "apps/v1";
kind = "Deployment";
metadata.name = "my-nginx";
spec = {
selector.matchLabels.run = "my-nginx";
replicas = 2;
template = {
metadata.labels.run = "my-nginx";
spec.containters = [
{
name = "my-nginx";
image = "nginx";
ports = [{ containerPort = 80; }];
}
];
};
};
}
{
apiVersion = "apps/v1";
kind = "Service";
metadata = {
name = "my-nginx";
labels.run = "my-nginx";
};
spec = {
ports = { port = 80; protocol = "TCP"; };
selector = { run = "my-nginx"; };
};
}
]

View file

@ -0,0 +1,33 @@
# real k8s configs use --- and not a top-level array
- apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 2
template:
metadata:
labels:
run: my-nginx
someOther: label
spec:
containers:
- name: my-nginx
image: nginx
ports:
- containerPort: 80
- apiVersion: v1
kind: Service
metadata:
name: my-nginx
labels:
run: my-nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
run: my-nginx