mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
first commit
This commit is contained in:
commit
cbf84e25a5
22 changed files with 131008 additions and 0 deletions
8
test/configMap.json
Normal file
8
test/configMap.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"apiVersion": "v1",
|
||||
"data": {
|
||||
"game.properties": "enemies=aliens\nlives=3\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.passphrase=UUDDLRLRBABAS\nsecret.code.allowed=true\nsecret.code.lives=30\n",
|
||||
"ui.properties": "color.good=purple\ncolor.bad=yellow\nallow.textmode=true\nhow.nice.to.look=fairlyNice\n"
|
||||
},
|
||||
"kind": "ConfigMap"
|
||||
}
|
||||
11
test/cr.json
Normal file
11
test/cr.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"apiVersion": "stable.example.com/v1",
|
||||
"kind": "CronTab",
|
||||
"metadata": {
|
||||
"name": "my-new-cron-object"
|
||||
},
|
||||
"spec": {
|
||||
"cronSpec": "* * * * */5",
|
||||
"image": "my-awesome-cron-image"
|
||||
}
|
||||
}
|
||||
20
test/crd.json
Normal file
20
test/crd.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"apiVersion": "apiextensions.k8s.io/v1beta1",
|
||||
"kind": "CustomResourceDefinition",
|
||||
"metadata": {
|
||||
"name": "crontabs.stable.example.com"
|
||||
},
|
||||
"spec": {
|
||||
"group": "stable.example.com",
|
||||
"version": "v1",
|
||||
"scope": "Namespaced",
|
||||
"names": {
|
||||
"plural": "crontabs",
|
||||
"singular": "crontab",
|
||||
"kind": "CronTab",
|
||||
"shortNames": [
|
||||
"ct"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
67
test/daemonset.json
Normal file
67
test/daemonset.json
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"kind": "DaemonSet",
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"k8s-app": "fluentd-logging"
|
||||
},
|
||||
"name": "fluentd-elasticsearch",
|
||||
"namespace": "kube-system"
|
||||
},
|
||||
"spec": {
|
||||
"selector": {
|
||||
"matchLabels": {
|
||||
"name": "fluentd-elasticsearch"
|
||||
}
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"name": "fluentd-elasticsearch"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"image": "gcr.io/google-containers/fluentd-elasticsearch:1.20",
|
||||
"name": "fluentd-elasticsearch",
|
||||
"resources": {
|
||||
"limits": {
|
||||
"memory": "200Mi"
|
||||
},
|
||||
"requests": {
|
||||
"cpu": "100m",
|
||||
"memory": "200Mi"
|
||||
}
|
||||
},
|
||||
"volumeMounts": [
|
||||
{
|
||||
"mountPath": "/var/log",
|
||||
"name": "varlog"
|
||||
},
|
||||
{
|
||||
"mountPath": "/var/lib/docker/containers",
|
||||
"name": "varlibdockercontainers",
|
||||
"readOnly": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"terminationGracePeriodSeconds": 30,
|
||||
"volumes": [
|
||||
{
|
||||
"hostPath": {
|
||||
"path": "/var/log"
|
||||
},
|
||||
"name": "varlog"
|
||||
},
|
||||
{
|
||||
"hostPath": {
|
||||
"path": "/var/lib/docker/containers"
|
||||
},
|
||||
"name": "varlibdockercontainers"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
test/default.nix
Normal file
7
test/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
kubernetes.version = "1.7";
|
||||
|
||||
require = [./modules.nix ./deployment.nix];
|
||||
}
|
||||
38
test/deployment.json
Normal file
38
test/deployment.json
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "nginx-deployment",
|
||||
"labels": {
|
||||
"app": "nginx"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"selector": {
|
||||
"matchLabels": {
|
||||
"app": "nginx"
|
||||
}
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"app": "nginx"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": {
|
||||
"nginx": {
|
||||
"name": "nginx",
|
||||
"image": "nginx:1.7.9",
|
||||
"ports": {
|
||||
"80": {}
|
||||
},
|
||||
"resources": {
|
||||
"requests": {
|
||||
"cpu": "100m"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
test/deployment.nix
Normal file
24
test/deployment.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{lib, k8s, ...}:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
kubernetes.resources = {
|
||||
deployments.deployment = mkMerge [
|
||||
(k8s.loadJSON ./deployment.json)
|
||||
{
|
||||
metadata.name = "abcd";
|
||||
nix.dependencies = ["configMaps/configmap"];
|
||||
}
|
||||
];
|
||||
configMaps.configmap = k8s.loadJSON ./configMap.json;
|
||||
namespaces.namespace = k8s.loadJSON ./namespace.json;
|
||||
daemonSets.daemonset = k8s.loadJSON ./daemonset.json;
|
||||
services.service = k8s.loadJSON ./service.json;
|
||||
customResourceDefinitions.cron = k8s.loadJSON ./crd.json;
|
||||
};
|
||||
|
||||
kubernetes.customResources.cron.my-awesome-cron-object = k8s.loadJSON ./cr.json;
|
||||
};
|
||||
}
|
||||
54
test/modules.nix
Normal file
54
test/modules.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{lib, k8s, ...}:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
kubernetes.moduleDefinitions.nginx.module = {name, config, ...}: {
|
||||
options = {
|
||||
port = mkOption {
|
||||
description = "Port for nginx to listen on";
|
||||
type = types.int;
|
||||
default = 80;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources.deployments.nginx = mkMerge [
|
||||
(k8s.loadJSON ./deployment.json)
|
||||
{
|
||||
metadata.name = "${name}-nginx";
|
||||
|
||||
spec.template.spec.containers.nginx.ports."80" = {
|
||||
containerPort = config.port;
|
||||
};
|
||||
|
||||
spec.template.spec.containers.nginx.env.name.valueFrom.secretKeyRef = {
|
||||
name = config.kubernetes.resources.configMaps.nginx.metadata.name;
|
||||
key = "somekey";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
kubernetes.resources.configMaps.nginx = mkMerge [
|
||||
(k8s.loadJSON ./configMap.json)
|
||||
{
|
||||
metadata.name = mkForce "${name}-nginx";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
kubernetes.modules.app-v1.module = "nginx";
|
||||
kubernetes.modules.app-v2 = {
|
||||
module = "nginx";
|
||||
configuration.port = 8080;
|
||||
};
|
||||
|
||||
kubernetes.resources.services.nginx = k8s.loadJSON ./service.json;
|
||||
|
||||
kubernetes.defaultModuleConfiguration = [{
|
||||
kubernetes.defaults.deployments.spec.replicas = 3;
|
||||
}];
|
||||
};
|
||||
}
|
||||
10
test/namespace.json
Normal file
10
test/namespace.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"kind": "Namespace",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "openshift-origin",
|
||||
"labels": {
|
||||
"name": "openshift-origin"
|
||||
}
|
||||
}
|
||||
}
|
||||
26
test/service.json
Normal file
26
test/service.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nginx"
|
||||
},
|
||||
"spec": {
|
||||
"selector": {
|
||||
"app": "nginx"
|
||||
},
|
||||
"ports": [
|
||||
{
|
||||
"name": "http",
|
||||
"protocol": "TCP",
|
||||
"port": 80,
|
||||
"targetPort": 80
|
||||
},
|
||||
{
|
||||
"name": "https",
|
||||
"protocol": "TCP",
|
||||
"port": 443,
|
||||
"targetPort": 443
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue