prvng_kcl/k8s_deploy.k
2025-10-07 11:17:54 +01:00

260 lines
5.8 KiB
Plaintext

# Info: KCL core lib service schemas for provisioning (Provisioning)
# Author: JesusPerezLorenzo
# Release: 0.0.4
# Date: 15-12-2023
schema K8sPort:
"""
K8S Port settings
"""
name: str
typ?: str = "TCP"
container?: int
nodePort?: int
target?: int
schema K8sKeyVal:
"""
K8S label,selector,env settings
"""
key: str
value: str
schema K8sKeyPath:
"""
K8S key,path settings
"""
key: str
path: str
schema K8sVolumeMount:
"""
K8S VolumeMounts settings
"""
name: str
readOnly: bool = False
mountPath: str
subPath?: str
schema K8sVolumeClaim:
"""
K8S VolumeClaim settings
"""
name: str
storageClassName: "manual" | "nfs-client" | "rook-cephfs" = "manual"
modes: ["ReadWriteOnce" | "ReadOnlyMain" | "ReadWriteMany" | "ReadWriteOncePod"] = ["ReadWriteOnce"]
abbrev_mode?: ["RWO" | "ROX" | "RWX" | "RWOP"] = ["RWO"]
reclaimPolicy?: "Recycle" | "Retain" | "Delete" = "Retain"
storage?: str
typ: "volumeClaim" | "configMap" | "secret" | "" = ""
pvMode?: "unspecified" | "Filesystem" | "Block"
pvcMode?: "unspecified" | "Filesystem" | "Block"
hostPath?: str
schema K8sConfigMap:
"""
K8S Volume ConfigMap settings
"""
name: str
schema K8sSecret:
"""
K8S Volume Secret settings
"""
name: str
items: [K8sKeyPath]
schema K8sVolume:
"""
K8S Volume settings
"""
name: str
typ: "volumeClaim" | "configMap" | "secret" = "volumeClaim"
persitentVolumeClaim?: K8sVolumeClaim
items?: [K8sKeyPath]
configMap?: K8sConfigMap
secret?: K8sSecret
schema K8sService:
"""
K8S Service settings
"""
name: str
typ: "ClusterIP" | "NodePort" | "LoadBalancer" | "ExternalName" | "Headless" | "None" = "ClusterIP"
externalName?: str
proto: "TCP" = "TCP"
ports: [K8sPort]
selector?: [K8sKeyVal]
externaIPs?: [str]
schema K8sContainers:
"""
K8S Container settings
"""
name: str = "main"
resources_requests?: K8sResources
resources_limits?: K8sResources
image: str
cmd?: str
imagePull: "IfNotPresent" | "Always" | "Never" = "IfNotPresent"
env?: [K8sKeyVal]
ports?: [K8sPort]
volumeMounts?: [K8sVolumeMount]
schema K8sBackup:
"""
K8S Backup settings
"""
name: str
typ: str
mount_path: str
schema K8sResources:
#"64Mi"
memory: str
#"250m"
cpu: str
schema K8sDeploySpec:
"""
K8S Deployment Spec settings
"""
# K8s Deploy replica
replicas: int = 1
hostUsers?: bool = True
# K8s Deploy containers
containers: [K8sContainers]
imagePullSecret?: str
nodeSelector?: [K8sKeyVal]
nodeName?: str
affinity?: K8sAffinity
# K8s Deploy Volumes
volumes?: [K8sVolume]
# K8s Secrets
secrets?: [K8sSecret]
schema K8sAffinityMatch:
"""
K8S Deployment Affinity Match settings
"""
key: str
operator: "In" | "NotIn" | "Exists" | "DoesNotExist"
values: [str]
schema K8sAffinityLabelSelector:
"""
K8S Deployment Affinity Label Selector settings
"""
typ: "requiredDuringSchedulingIgnoredDuringExecution" | "preferredDuringSchedulingIgnoredDuringExecution" = "requiredDuringSchedulingIgnoredDuringExecution"
labelSelector: [K8sAffinityMatch]
# example: topology.kubernetes.io/zon
topologyKey?: str
matchLabelKeys?: [str]
schema K8sPrxyTLS:
"""
K8S Deployment Proxy TLS settings
"""
httpsRedirect?: bool = False
mode?: "SIMPLE" | "PASSTHROUGH" | "MULTI" | "" = "SIMPLE"
credentialName?: str
schema K8sPrxyPort:
"""
K8S Proxy Port settings
"""
name: str
number?: int
proto: "HTTP" | "HTTPS" | "TCP" = "HTTPS"
schema K8sPrxyGatewayServer:
"""
K8S Deployment Proxy Gateway Server settings
"""
port: K8sPrxyPort
tls?: K8sPrxyTLS
hosts?: [str]
schema K8sPrxyVirtualServiceRoute:
"""
K8S Deployment Proxy Virtual Service Route settings
"""
port_number: int
host: str
schema K8sPrxyVirtualServiceMatchURL:
"""
K8S Deployment Proxy Virtual Service Match URL settings
"""
port?: int
sniHost?: [str]
schema K8sPrxyVirtualServiceMatch:
"""
K8S Deployment Proxy Virtual Service Match settings
"""
typ: "tcp" | "http" | "tls"
location?: [K8sPrxyVirtualServiceMatchURL]
route_destination?: [K8sPrxyVirtualServiceRoute]
schema K8sPrxyVirtualService:
"""
K8S Deployment Proxy Virtual Service settings
"""
hosts: [str]
gateways: [str]
matches?: [K8sPrxyVirtualServiceMatch]
schema K8sAntyAffinityLabelSelector(K8sAffinityLabelSelector):
"""
K8S Deployment AntyAffinity Label Selector settings
"""
weight: int = 100
schema K8sAffinity:
"""
K8S Deployment Affinity settings
"""
affinity?: K8sAffinityLabelSelector
antiAffinity?: K8sAntyAffinityLabelSelector
schema K8sDefs:
name: str
ns: str
domain: str
full_domain: str
primary_dom: str
cluster_domain: str
schema K8sDeploy:
"""
K8S Deployment settings
"""
# K8s Deploy Name
name: str
# K8s Deploy name-in-filenames
name_in_files: str = "${name}"
# K8s NameSpace
namespace: str | "default"
# K8s Create NameSpace
create_ns: bool = False
full_domain?: str
# K8s Deploy labels
labels: [K8sKeyVal] = [K8sKeyVal {key: "${name}", value: "${name}"}]
sel_labels: [K8sKeyVal] = labels
tpl_labels: [K8sKeyVal] = labels
spec: K8sDeploySpec
# Cluster Ingres Proxy to use
prxy?: "istio"
prxy_ns?: str = "istio-system"
prxyGatewayServers?: [K8sPrxyGatewayServer]
prxyVirtualService?: K8sPrxyVirtualService
# TSL certs path for service
tls_path?: str = "ssl"
# Create bin/apply.sh
bin_apply: bool = True
# K8s Service
service?: K8sService
# Service Backup K8s JOB
backups?: [K8sBackup]