mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
feat(k8s): support for yaml/json imports
This commit is contained in:
parent
db5ee88274
commit
5e29229879
5 changed files with 104 additions and 20 deletions
21
tests/k8s/deployment.yaml
Normal file
21
tests/k8s/deployment.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:1.7.9
|
||||
ports:
|
||||
- containerPort: 80
|
||||
30
tests/k8s/imports.nix
Normal file
30
tests/k8s/imports.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ config, lib, kubenix, k8sVersion, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
pod = config.kubernetes.api.core.v1.Pod.test;
|
||||
deployment = config.kubernetes.api.apps.v1.Deployment.nginx-deployment;
|
||||
in {
|
||||
imports = with kubenix.modules; [ test k8s ];
|
||||
|
||||
test = {
|
||||
name = "k8s-imports";
|
||||
description = "Simple k8s testing imports";
|
||||
enable = builtins.compareVersions config.kubernetes.version "1.10" >= 0;
|
||||
assertions = [{
|
||||
message = "Pod should have name set";
|
||||
assertion = pod.metadata.name == "test";
|
||||
} {
|
||||
message = "Deployment should have name set";
|
||||
assertion = deployment.metadata.name == "nginx-deployment";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.version = k8sVersion;
|
||||
|
||||
kubernetes.imports = [
|
||||
./pod.json
|
||||
./deployment.yaml
|
||||
];
|
||||
}
|
||||
13
tests/k8s/pod.json
Normal file
13
tests/k8s/pod.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"kind": "Pod",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "test"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "test",
|
||||
"image": "busybox"
|
||||
}]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue