Skip to content

Commit

Permalink
feat(config): Refactor config value namming
Browse files Browse the repository at this point in the history
  • Loading branch information
yyvess committed Feb 4, 2024
1 parent e61aa95 commit d6f503c
Show file tree
Hide file tree
Showing 21 changed files with 345 additions and 332 deletions.
43 changes: 22 additions & 21 deletions samples/ha/postgres-istio-values.cue
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@ values: {
"keycloak.myorg.com",
]
}
issuerCreate: true
jksCreate: true
networkPolicyCreate: true

networkPolicyRules: [{
from: [{
namespaceSelector: {
matchLabels: {
"kubernetes.io/metadata.name": "istio-system"
issuer: enabled: true
jks: enabled: true
networkPolicy: {
enabled: true
rules: [{
from: [{
namespaceSelector: {
matchLabels: {
"kubernetes.io/metadata.name": "istio-system"
}
}
}
podSelector: {
matchLabels: {
app: "istio-ingressgateway"
podSelector: {
matchLabels: {
app: "istio-ingressgateway"
}
}
}
},
},
]
ports: [{
protocol: "TCP"
port: 8080
},
]},
]
ports: [{
protocol: "TCP"
port: 8080
},
]},
]
}
admin: {
password: {value: "FIXME-USE-SECRET"}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/minimum/ingress-pvc-values.cue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ values: {

#hostname: "keycloak.kube-playground.tolron.fr"

pvcCreate: true
pvc: {
enabled: true
size: "100M"
storageClassName: "sc-kube-playground"
}
Expand Down
6 changes: 3 additions & 3 deletions templates/certificates.cue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
#Certificate: v1.#Certificate & {
#config: #Config
metadata: #config.metadata
spec: #config.certificate & {
spec: #config.certificate.spec & {
issuerRef: {
group: "cert-manager.io"
kind: "Issuer"
Expand Down Expand Up @@ -42,7 +42,7 @@ import (
#Meta: #config.metadata
#Component: "jks"
}
spec: #config.jks & {
spec: #config.jks.spec & {
issuerRef: {
group: "cert-manager.io"
kind: "Issuer"
Expand All @@ -62,5 +62,5 @@ import (
#Issuer: issuerv1.#Issuer & {
#config: #Config
metadata: #config.metadata
spec: #config.issuer
spec: #config.issuer.spec
}
53 changes: 27 additions & 26 deletions templates/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import (
port: *[if https {8443}, {8080}][0] | int & >0 & <=65535
}

// Pod ports
// Pod exposed ports
httpPort?: int & >0 & <=65535
if (service.https) {
httpsPort?: int & >0 & <=65535
Expand All @@ -111,55 +111,56 @@ import (

extraEnvs: [...corev1.#EnvVar] | *[]

serviceAccountCreate: *false | bool
serviceAccount: corev1.#ServiceAccount
serviceAccount: {
enabled: *false | bool
}

// Issuer used to generate certificate & jks
issuerCreate: *false | bool
if (issuerCreate) {
issuer: issuerv1.#IssuerSpec | *{
issuer: {
enabled: *false | bool
spec: issuerv1.#IssuerSpec | *{
selfSigned: {}
}
}

certificateCreate: *false | bool
if (certificateCreate) {
// Web certificate
certificate: certv1.#CertificateSpec & {
// Web certificate
certificate: {
enabled: *false | bool
spec: certv1.#CertificateSpec & {
dnsNames: *["localhost:\( service.port )"] | [...string]
issuerRef: name: *"\(metadata.name)" | string
secretName: "\(metadata.name)-cert"
}
}

jksCreate: *false | bool
if (jksCreate) {
// Requird to securize Jgroup
jks: certv1.#CertificateSpec & {
// Jks certificate for Jgroup
jks: {
enabled: *false | bool
spec: certv1.#CertificateSpec & {
commonName: *"infinispan-jks" | string
issuerRef: name: *"\(metadata.name)" | string
secretName: "\(metadata.name)-jks"
}
}

pdbCreate: bool | *(replicas > 1)
if (pdbCreate) {
pdb: policyv1.#PodDisruptionBudgetSpec & {
pdb: {
enabled: bool | *(replicas > 1)
spec: policyv1.#PodDisruptionBudgetSpec & {
minAvailable: *1 | int & >0 & <=65535
}
}

networkPolicyCreate: *false | bool
if (networkPolicyCreate) {
networkPolicyRules: [... netv1.#NetworkPolicyIngressRule]
networkPolicy: {
enabled: *false | bool
if networkPolicy.enabled {
rules: [... netv1.#NetworkPolicyIngressRule]
}
}

pvcCreate: [if replicas > 1 {false}, bool | *false][0]
if (pvcCreate) {
pvc: {
storageClassName: string
size: string | *"5Gi"
}
pvc: {
enabled: [if replicas > 1 {false}, bool | *false][0]
storageClassName: *"standard" | string
size: *"1Gi" | string
}

virtualService?: vsv1beta1.#VirtualServiceSpec
Expand Down
Loading

0 comments on commit d6f503c

Please sign in to comment.