@crossdelta/infrastructure 0.2.23 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +185 -164
- package/dist/index.js +185 -164
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -337855,13 +337855,7 @@ function getImagePullPolicy(image2, explicit) {
|
|
|
337855
337855
|
return explicit;
|
|
337856
337856
|
return image2.endsWith(":latest") ? "Always" : "IfNotPresent";
|
|
337857
337857
|
}
|
|
337858
|
-
function
|
|
337859
|
-
if (!config2.image) {
|
|
337860
|
-
throw new Error(`Missing "image" for service "${config2.name}". Either specify image explicitly or use discoverServiceConfigs() which auto-generates it from pf.registry.`);
|
|
337861
|
-
}
|
|
337862
|
-
const labels = buildLabels(config2.name, config2.labels);
|
|
337863
|
-
const replicas = config2.replicas ?? DEFAULTS.replicas;
|
|
337864
|
-
const imagePullPolicy = getImagePullPolicy(config2.image, config2.imagePullPolicy);
|
|
337858
|
+
function buildEnvVars(config2) {
|
|
337865
337859
|
const envVars = [];
|
|
337866
337860
|
envVars.push({ name: "PORT", value: String(config2.containerPort) });
|
|
337867
337861
|
if (config2.env) {
|
|
@@ -337869,17 +337863,7 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337869
337863
|
envVars.push({ name: key, value: pulumi6.output(value) });
|
|
337870
337864
|
}
|
|
337871
337865
|
}
|
|
337872
|
-
|
|
337873
|
-
if (config2.secrets && Object.keys(config2.secrets).length > 0) {
|
|
337874
|
-
secret = new k8s5.core.v1.Secret(`${config2.name}-secret`, {
|
|
337875
|
-
metadata: {
|
|
337876
|
-
name: `${config2.name}-secret`,
|
|
337877
|
-
namespace,
|
|
337878
|
-
labels
|
|
337879
|
-
},
|
|
337880
|
-
type: "Opaque",
|
|
337881
|
-
stringData: config2.secrets
|
|
337882
|
-
}, { provider });
|
|
337866
|
+
if (config2.secrets) {
|
|
337883
337867
|
for (const key of Object.keys(config2.secrets)) {
|
|
337884
337868
|
envVars.push({
|
|
337885
337869
|
name: key,
|
|
@@ -337892,80 +337876,205 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337892
337876
|
});
|
|
337893
337877
|
}
|
|
337894
337878
|
}
|
|
337879
|
+
return envVars;
|
|
337880
|
+
}
|
|
337881
|
+
function createServiceSecret(provider, namespace, config2, labels) {
|
|
337882
|
+
if (!config2.secrets || Object.keys(config2.secrets).length === 0) {
|
|
337883
|
+
return;
|
|
337884
|
+
}
|
|
337885
|
+
return new k8s5.core.v1.Secret(`${config2.name}-secret`, {
|
|
337886
|
+
metadata: {
|
|
337887
|
+
name: `${config2.name}-secret`,
|
|
337888
|
+
namespace,
|
|
337889
|
+
labels
|
|
337890
|
+
},
|
|
337891
|
+
type: "Opaque",
|
|
337892
|
+
stringData: config2.secrets
|
|
337893
|
+
}, { provider });
|
|
337894
|
+
}
|
|
337895
|
+
function createServiceVolumes(provider, namespace, config2, labels) {
|
|
337895
337896
|
const pvcs = [];
|
|
337896
337897
|
const volumeMounts = [];
|
|
337897
337898
|
const volumes = [];
|
|
337898
|
-
if (config2.volumes) {
|
|
337899
|
-
|
|
337900
|
-
|
|
337901
|
-
|
|
337902
|
-
|
|
337903
|
-
|
|
337904
|
-
|
|
337905
|
-
|
|
337906
|
-
|
|
337907
|
-
|
|
337908
|
-
|
|
337909
|
-
|
|
337910
|
-
|
|
337911
|
-
|
|
337912
|
-
|
|
337913
|
-
}
|
|
337914
|
-
}
|
|
337915
|
-
}, { provider });
|
|
337916
|
-
pvcs.push(pvc);
|
|
337917
|
-
volumeMounts.push({
|
|
337918
|
-
name: vol.name,
|
|
337919
|
-
mountPath: vol.mountPath,
|
|
337920
|
-
readOnly: vol.readOnly
|
|
337921
|
-
});
|
|
337922
|
-
volumes.push({
|
|
337923
|
-
name: vol.name,
|
|
337924
|
-
persistentVolumeClaim: {
|
|
337925
|
-
claimName: `${config2.name}-${vol.name}`
|
|
337899
|
+
if (!config2.volumes) {
|
|
337900
|
+
return { pvcs, volumeMounts, volumes };
|
|
337901
|
+
}
|
|
337902
|
+
for (const vol of config2.volumes) {
|
|
337903
|
+
const pvc = new k8s5.core.v1.PersistentVolumeClaim(`${config2.name}-${vol.name}`, {
|
|
337904
|
+
metadata: {
|
|
337905
|
+
name: `${config2.name}-${vol.name}`,
|
|
337906
|
+
namespace,
|
|
337907
|
+
labels
|
|
337908
|
+
},
|
|
337909
|
+
spec: {
|
|
337910
|
+
accessModes: [vol.accessMode ?? "ReadWriteOnce"],
|
|
337911
|
+
storageClassName: vol.storageClass ?? "do-block-storage",
|
|
337912
|
+
resources: {
|
|
337913
|
+
requests: { storage: vol.size ?? "10Gi" }
|
|
337926
337914
|
}
|
|
337927
|
-
}
|
|
337928
|
-
}
|
|
337915
|
+
}
|
|
337916
|
+
}, { provider });
|
|
337917
|
+
pvcs.push(pvc);
|
|
337918
|
+
volumeMounts.push({
|
|
337919
|
+
name: vol.name,
|
|
337920
|
+
mountPath: vol.mountPath,
|
|
337921
|
+
readOnly: vol.readOnly
|
|
337922
|
+
});
|
|
337923
|
+
volumes.push({
|
|
337924
|
+
name: vol.name,
|
|
337925
|
+
persistentVolumeClaim: {
|
|
337926
|
+
claimName: `${config2.name}-${vol.name}`
|
|
337927
|
+
}
|
|
337928
|
+
});
|
|
337929
337929
|
}
|
|
337930
|
+
return { pvcs, volumeMounts, volumes };
|
|
337931
|
+
}
|
|
337932
|
+
function buildHealthProbes(config2) {
|
|
337930
337933
|
const healthCheck = config2.healthCheck;
|
|
337931
|
-
|
|
337932
|
-
|
|
337933
|
-
if (healthCheck) {
|
|
337934
|
-
const probeConfig = {
|
|
337935
|
-
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
337936
|
-
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
337937
|
-
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
337938
|
-
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
337939
|
-
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
337940
|
-
};
|
|
337941
|
-
if (healthCheck.httpPath) {
|
|
337942
|
-
const httpGet = {
|
|
337943
|
-
path: healthCheck.httpPath,
|
|
337944
|
-
port: healthCheck.port ?? config2.containerPort
|
|
337945
|
-
};
|
|
337946
|
-
livenessProbe = { ...probeConfig, httpGet };
|
|
337947
|
-
readinessProbe = { ...probeConfig, httpGet };
|
|
337948
|
-
} else {
|
|
337949
|
-
const tcpSocket = {
|
|
337950
|
-
port: healthCheck.port ?? config2.containerPort
|
|
337951
|
-
};
|
|
337952
|
-
livenessProbe = { ...probeConfig, tcpSocket };
|
|
337953
|
-
readinessProbe = { ...probeConfig, tcpSocket };
|
|
337954
|
-
}
|
|
337934
|
+
if (!healthCheck) {
|
|
337935
|
+
return {};
|
|
337955
337936
|
}
|
|
337956
|
-
const
|
|
337957
|
-
|
|
337937
|
+
const probeConfig = {
|
|
337938
|
+
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
337939
|
+
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
337940
|
+
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
337941
|
+
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
337942
|
+
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
337943
|
+
};
|
|
337944
|
+
if (healthCheck.httpPath) {
|
|
337945
|
+
const httpGet = {
|
|
337946
|
+
path: healthCheck.httpPath,
|
|
337947
|
+
port: healthCheck.port ?? config2.containerPort
|
|
337948
|
+
};
|
|
337949
|
+
return {
|
|
337950
|
+
livenessProbe: { ...probeConfig, httpGet },
|
|
337951
|
+
readinessProbe: { ...probeConfig, httpGet }
|
|
337952
|
+
};
|
|
337953
|
+
}
|
|
337954
|
+
const tcpSocket = { port: healthCheck.port ?? config2.containerPort };
|
|
337955
|
+
return {
|
|
337956
|
+
livenessProbe: { ...probeConfig, tcpSocket },
|
|
337957
|
+
readinessProbe: { ...probeConfig, tcpSocket }
|
|
337958
|
+
};
|
|
337959
|
+
}
|
|
337960
|
+
function buildContainerPorts(config2) {
|
|
337961
|
+
const ports = [
|
|
337958
337962
|
{ containerPort: config2.containerPort, name: "http" }
|
|
337959
337963
|
];
|
|
337960
337964
|
if (config2.additionalPorts) {
|
|
337961
337965
|
for (const port of config2.additionalPorts) {
|
|
337962
|
-
|
|
337966
|
+
ports.push({
|
|
337963
337967
|
containerPort: port.targetPort ?? port.port,
|
|
337964
337968
|
name: port.name,
|
|
337965
337969
|
protocol: port.protocol ?? "TCP"
|
|
337966
337970
|
});
|
|
337967
337971
|
}
|
|
337968
337972
|
}
|
|
337973
|
+
return ports;
|
|
337974
|
+
}
|
|
337975
|
+
function buildServicePorts(config2) {
|
|
337976
|
+
const ports = [
|
|
337977
|
+
{
|
|
337978
|
+
name: "http",
|
|
337979
|
+
port: config2.containerPort,
|
|
337980
|
+
targetPort: config2.containerPort,
|
|
337981
|
+
protocol: "TCP"
|
|
337982
|
+
}
|
|
337983
|
+
];
|
|
337984
|
+
if (config2.additionalPorts) {
|
|
337985
|
+
for (const port of config2.additionalPorts) {
|
|
337986
|
+
ports.push({
|
|
337987
|
+
name: port.name,
|
|
337988
|
+
port: port.port,
|
|
337989
|
+
targetPort: port.targetPort ?? port.port,
|
|
337990
|
+
protocol: port.protocol ?? "TCP"
|
|
337991
|
+
});
|
|
337992
|
+
}
|
|
337993
|
+
}
|
|
337994
|
+
return ports;
|
|
337995
|
+
}
|
|
337996
|
+
function createServiceIngress(provider, namespace, config2, labels, service) {
|
|
337997
|
+
if (!config2.ingress) {
|
|
337998
|
+
return;
|
|
337999
|
+
}
|
|
338000
|
+
const ingressAnnotations = {
|
|
338001
|
+
"kubernetes.io/ingress.class": "nginx",
|
|
338002
|
+
...config2.ingress.annotations
|
|
338003
|
+
};
|
|
338004
|
+
if (config2.ingress.tls?.enabled) {
|
|
338005
|
+
ingressAnnotations["cert-manager.io/cluster-issuer"] = config2.ingress.tls.issuerName ?? "letsencrypt-production";
|
|
338006
|
+
}
|
|
338007
|
+
let ingressPath = config2.ingress.path;
|
|
338008
|
+
let ingressPathType = config2.ingress.pathType ?? "Prefix";
|
|
338009
|
+
const shouldStripPrefix = config2.ingress.path !== "/" && !config2.ingress.keepPrefix;
|
|
338010
|
+
if (shouldStripPrefix) {
|
|
338011
|
+
ingressPath = `${config2.ingress.path}(/|$)(.*)`;
|
|
338012
|
+
ingressPathType = "ImplementationSpecific";
|
|
338013
|
+
ingressAnnotations["nginx.ingress.kubernetes.io/use-regex"] = "true";
|
|
338014
|
+
ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$2";
|
|
338015
|
+
}
|
|
338016
|
+
const createRule = (host) => ({
|
|
338017
|
+
...host && { host },
|
|
338018
|
+
http: {
|
|
338019
|
+
paths: [
|
|
338020
|
+
{
|
|
338021
|
+
path: ingressPath,
|
|
338022
|
+
pathType: ingressPathType,
|
|
338023
|
+
backend: {
|
|
338024
|
+
service: {
|
|
338025
|
+
name: config2.name,
|
|
338026
|
+
port: { number: config2.containerPort }
|
|
338027
|
+
}
|
|
338028
|
+
}
|
|
338029
|
+
}
|
|
338030
|
+
]
|
|
338031
|
+
}
|
|
338032
|
+
});
|
|
338033
|
+
const ingressRules = [];
|
|
338034
|
+
if (config2.ingress.host) {
|
|
338035
|
+
ingressRules.push(createRule(config2.ingress.host));
|
|
338036
|
+
} else {
|
|
338037
|
+
ingressRules.push(createRule());
|
|
338038
|
+
}
|
|
338039
|
+
if (config2.ingress.additionalHosts) {
|
|
338040
|
+
for (const additionalHost of config2.ingress.additionalHosts) {
|
|
338041
|
+
ingressRules.push(createRule(additionalHost));
|
|
338042
|
+
}
|
|
338043
|
+
}
|
|
338044
|
+
const allHosts = [
|
|
338045
|
+
...config2.ingress.host ? [config2.ingress.host] : [],
|
|
338046
|
+
...config2.ingress.additionalHosts ?? []
|
|
338047
|
+
];
|
|
338048
|
+
const tlsSecretName = config2.ingress.tls?.secretName ?? `${config2.name}-tls`;
|
|
338049
|
+
return new k8s5.networking.v1.Ingress(`${config2.name}-ingress`, {
|
|
338050
|
+
metadata: {
|
|
338051
|
+
name: config2.name,
|
|
338052
|
+
namespace,
|
|
338053
|
+
labels,
|
|
338054
|
+
annotations: ingressAnnotations
|
|
338055
|
+
},
|
|
338056
|
+
spec: {
|
|
338057
|
+
...config2.ingress.tls?.enabled && allHosts.length > 0 && {
|
|
338058
|
+
tls: [{ hosts: allHosts, secretName: tlsSecretName }]
|
|
338059
|
+
},
|
|
338060
|
+
rules: ingressRules
|
|
338061
|
+
}
|
|
338062
|
+
}, { provider, dependsOn: [service] });
|
|
338063
|
+
}
|
|
338064
|
+
function deployK8sService(provider, namespace, config2) {
|
|
338065
|
+
if (!config2.image) {
|
|
338066
|
+
throw new Error(`Missing "image" for service "${config2.name}". Either specify image explicitly or use discoverServiceConfigs() which auto-generates it from pf.registry.`);
|
|
338067
|
+
}
|
|
338068
|
+
const labels = buildLabels(config2.name, config2.labels);
|
|
338069
|
+
const replicas = config2.replicas ?? DEFAULTS.replicas;
|
|
338070
|
+
const imagePullPolicy = getImagePullPolicy(config2.image, config2.imagePullPolicy);
|
|
338071
|
+
const resources = config2.resources ?? DEFAULTS.resources;
|
|
338072
|
+
const secret = createServiceSecret(provider, namespace, config2, labels);
|
|
338073
|
+
const envVars = buildEnvVars(config2);
|
|
338074
|
+
const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, config2, labels);
|
|
338075
|
+
const { livenessProbe, readinessProbe } = buildHealthProbes(config2);
|
|
338076
|
+
const containerPorts = buildContainerPorts(config2);
|
|
338077
|
+
const servicePorts = buildServicePorts(config2);
|
|
337969
338078
|
const deployment = new k8s5.apps.v1.Deployment(`${config2.name}-deployment`, {
|
|
337970
338079
|
metadata: {
|
|
337971
338080
|
name: config2.name,
|
|
@@ -338007,24 +338116,6 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
338007
338116
|
}
|
|
338008
338117
|
}
|
|
338009
338118
|
}, { provider, dependsOn: pvcs.length > 0 ? pvcs : undefined });
|
|
338010
|
-
const servicePorts = [
|
|
338011
|
-
{
|
|
338012
|
-
name: "http",
|
|
338013
|
-
port: config2.containerPort,
|
|
338014
|
-
targetPort: config2.containerPort,
|
|
338015
|
-
protocol: "TCP"
|
|
338016
|
-
}
|
|
338017
|
-
];
|
|
338018
|
-
if (config2.additionalPorts) {
|
|
338019
|
-
for (const port of config2.additionalPorts) {
|
|
338020
|
-
servicePorts.push({
|
|
338021
|
-
name: port.name,
|
|
338022
|
-
port: port.port,
|
|
338023
|
-
targetPort: port.targetPort ?? port.port,
|
|
338024
|
-
protocol: port.protocol ?? "TCP"
|
|
338025
|
-
});
|
|
338026
|
-
}
|
|
338027
|
-
}
|
|
338028
338119
|
const service = new k8s5.core.v1.Service(`${config2.name}-service`, {
|
|
338029
338120
|
metadata: {
|
|
338030
338121
|
name: config2.name,
|
|
@@ -338037,77 +338128,7 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
338037
338128
|
ports: servicePorts
|
|
338038
338129
|
}
|
|
338039
338130
|
}, { provider, dependsOn: [deployment] });
|
|
338040
|
-
|
|
338041
|
-
if (config2.ingress) {
|
|
338042
|
-
const ingressAnnotations = {
|
|
338043
|
-
"kubernetes.io/ingress.class": "nginx",
|
|
338044
|
-
...config2.ingress.annotations
|
|
338045
|
-
};
|
|
338046
|
-
if (config2.ingress.tls?.enabled) {
|
|
338047
|
-
ingressAnnotations["cert-manager.io/cluster-issuer"] = config2.ingress.tls.issuerName ?? "letsencrypt-production";
|
|
338048
|
-
}
|
|
338049
|
-
let ingressPath = config2.ingress.path;
|
|
338050
|
-
let ingressPathType = config2.ingress.pathType ?? "Prefix";
|
|
338051
|
-
const shouldStripPrefix = config2.ingress.path !== "/" && !config2.ingress.keepPrefix;
|
|
338052
|
-
if (shouldStripPrefix) {
|
|
338053
|
-
ingressPath = `${config2.ingress.path}(/|$)(.*)`;
|
|
338054
|
-
ingressPathType = "ImplementationSpecific";
|
|
338055
|
-
ingressAnnotations["nginx.ingress.kubernetes.io/use-regex"] = "true";
|
|
338056
|
-
ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$2";
|
|
338057
|
-
}
|
|
338058
|
-
const tlsSecretName = config2.ingress.tls?.secretName ?? `${config2.name}-tls`;
|
|
338059
|
-
const ingressRules = [];
|
|
338060
|
-
const createRule = (host) => ({
|
|
338061
|
-
...host && { host },
|
|
338062
|
-
http: {
|
|
338063
|
-
paths: [
|
|
338064
|
-
{
|
|
338065
|
-
path: ingressPath,
|
|
338066
|
-
pathType: ingressPathType,
|
|
338067
|
-
backend: {
|
|
338068
|
-
service: {
|
|
338069
|
-
name: config2.name,
|
|
338070
|
-
port: { number: config2.containerPort }
|
|
338071
|
-
}
|
|
338072
|
-
}
|
|
338073
|
-
}
|
|
338074
|
-
]
|
|
338075
|
-
}
|
|
338076
|
-
});
|
|
338077
|
-
if (config2.ingress.host) {
|
|
338078
|
-
ingressRules.push(createRule(config2.ingress.host));
|
|
338079
|
-
} else {
|
|
338080
|
-
ingressRules.push(createRule());
|
|
338081
|
-
}
|
|
338082
|
-
if (config2.ingress.additionalHosts) {
|
|
338083
|
-
for (const additionalHost of config2.ingress.additionalHosts) {
|
|
338084
|
-
ingressRules.push(createRule(additionalHost));
|
|
338085
|
-
}
|
|
338086
|
-
}
|
|
338087
|
-
const allHosts = [
|
|
338088
|
-
...config2.ingress.host ? [config2.ingress.host] : [],
|
|
338089
|
-
...config2.ingress.additionalHosts ?? []
|
|
338090
|
-
];
|
|
338091
|
-
ingress = new k8s5.networking.v1.Ingress(`${config2.name}-ingress`, {
|
|
338092
|
-
metadata: {
|
|
338093
|
-
name: config2.name,
|
|
338094
|
-
namespace,
|
|
338095
|
-
labels,
|
|
338096
|
-
annotations: ingressAnnotations
|
|
338097
|
-
},
|
|
338098
|
-
spec: {
|
|
338099
|
-
...config2.ingress.tls?.enabled && allHosts.length > 0 && {
|
|
338100
|
-
tls: [
|
|
338101
|
-
{
|
|
338102
|
-
hosts: allHosts,
|
|
338103
|
-
secretName: tlsSecretName
|
|
338104
|
-
}
|
|
338105
|
-
]
|
|
338106
|
-
},
|
|
338107
|
-
rules: ingressRules
|
|
338108
|
-
}
|
|
338109
|
-
}, { provider, dependsOn: [service] });
|
|
338110
|
-
}
|
|
338131
|
+
const ingress = createServiceIngress(provider, namespace, config2, labels, service);
|
|
338111
338132
|
const serviceDns = `${config2.name}.${namespace}.svc.cluster.local`;
|
|
338112
338133
|
const internalUrl = pulumi6.output(`http://${serviceDns}:${config2.containerPort}`);
|
|
338113
338134
|
return {
|
package/dist/index.js
CHANGED
|
@@ -337779,13 +337779,7 @@ function getImagePullPolicy(image2, explicit) {
|
|
|
337779
337779
|
return explicit;
|
|
337780
337780
|
return image2.endsWith(":latest") ? "Always" : "IfNotPresent";
|
|
337781
337781
|
}
|
|
337782
|
-
function
|
|
337783
|
-
if (!config2.image) {
|
|
337784
|
-
throw new Error(`Missing "image" for service "${config2.name}". Either specify image explicitly or use discoverServiceConfigs() which auto-generates it from pf.registry.`);
|
|
337785
|
-
}
|
|
337786
|
-
const labels = buildLabels(config2.name, config2.labels);
|
|
337787
|
-
const replicas = config2.replicas ?? DEFAULTS.replicas;
|
|
337788
|
-
const imagePullPolicy = getImagePullPolicy(config2.image, config2.imagePullPolicy);
|
|
337782
|
+
function buildEnvVars(config2) {
|
|
337789
337783
|
const envVars = [];
|
|
337790
337784
|
envVars.push({ name: "PORT", value: String(config2.containerPort) });
|
|
337791
337785
|
if (config2.env) {
|
|
@@ -337793,17 +337787,7 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337793
337787
|
envVars.push({ name: key, value: pulumi6.output(value) });
|
|
337794
337788
|
}
|
|
337795
337789
|
}
|
|
337796
|
-
|
|
337797
|
-
if (config2.secrets && Object.keys(config2.secrets).length > 0) {
|
|
337798
|
-
secret = new k8s5.core.v1.Secret(`${config2.name}-secret`, {
|
|
337799
|
-
metadata: {
|
|
337800
|
-
name: `${config2.name}-secret`,
|
|
337801
|
-
namespace,
|
|
337802
|
-
labels
|
|
337803
|
-
},
|
|
337804
|
-
type: "Opaque",
|
|
337805
|
-
stringData: config2.secrets
|
|
337806
|
-
}, { provider });
|
|
337790
|
+
if (config2.secrets) {
|
|
337807
337791
|
for (const key of Object.keys(config2.secrets)) {
|
|
337808
337792
|
envVars.push({
|
|
337809
337793
|
name: key,
|
|
@@ -337816,80 +337800,205 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337816
337800
|
});
|
|
337817
337801
|
}
|
|
337818
337802
|
}
|
|
337803
|
+
return envVars;
|
|
337804
|
+
}
|
|
337805
|
+
function createServiceSecret(provider, namespace, config2, labels) {
|
|
337806
|
+
if (!config2.secrets || Object.keys(config2.secrets).length === 0) {
|
|
337807
|
+
return;
|
|
337808
|
+
}
|
|
337809
|
+
return new k8s5.core.v1.Secret(`${config2.name}-secret`, {
|
|
337810
|
+
metadata: {
|
|
337811
|
+
name: `${config2.name}-secret`,
|
|
337812
|
+
namespace,
|
|
337813
|
+
labels
|
|
337814
|
+
},
|
|
337815
|
+
type: "Opaque",
|
|
337816
|
+
stringData: config2.secrets
|
|
337817
|
+
}, { provider });
|
|
337818
|
+
}
|
|
337819
|
+
function createServiceVolumes(provider, namespace, config2, labels) {
|
|
337819
337820
|
const pvcs = [];
|
|
337820
337821
|
const volumeMounts = [];
|
|
337821
337822
|
const volumes = [];
|
|
337822
|
-
if (config2.volumes) {
|
|
337823
|
-
|
|
337824
|
-
|
|
337825
|
-
|
|
337826
|
-
|
|
337827
|
-
|
|
337828
|
-
|
|
337829
|
-
|
|
337830
|
-
|
|
337831
|
-
|
|
337832
|
-
|
|
337833
|
-
|
|
337834
|
-
|
|
337835
|
-
|
|
337836
|
-
|
|
337837
|
-
}
|
|
337838
|
-
}
|
|
337839
|
-
}, { provider });
|
|
337840
|
-
pvcs.push(pvc);
|
|
337841
|
-
volumeMounts.push({
|
|
337842
|
-
name: vol.name,
|
|
337843
|
-
mountPath: vol.mountPath,
|
|
337844
|
-
readOnly: vol.readOnly
|
|
337845
|
-
});
|
|
337846
|
-
volumes.push({
|
|
337847
|
-
name: vol.name,
|
|
337848
|
-
persistentVolumeClaim: {
|
|
337849
|
-
claimName: `${config2.name}-${vol.name}`
|
|
337823
|
+
if (!config2.volumes) {
|
|
337824
|
+
return { pvcs, volumeMounts, volumes };
|
|
337825
|
+
}
|
|
337826
|
+
for (const vol of config2.volumes) {
|
|
337827
|
+
const pvc = new k8s5.core.v1.PersistentVolumeClaim(`${config2.name}-${vol.name}`, {
|
|
337828
|
+
metadata: {
|
|
337829
|
+
name: `${config2.name}-${vol.name}`,
|
|
337830
|
+
namespace,
|
|
337831
|
+
labels
|
|
337832
|
+
},
|
|
337833
|
+
spec: {
|
|
337834
|
+
accessModes: [vol.accessMode ?? "ReadWriteOnce"],
|
|
337835
|
+
storageClassName: vol.storageClass ?? "do-block-storage",
|
|
337836
|
+
resources: {
|
|
337837
|
+
requests: { storage: vol.size ?? "10Gi" }
|
|
337850
337838
|
}
|
|
337851
|
-
}
|
|
337852
|
-
}
|
|
337839
|
+
}
|
|
337840
|
+
}, { provider });
|
|
337841
|
+
pvcs.push(pvc);
|
|
337842
|
+
volumeMounts.push({
|
|
337843
|
+
name: vol.name,
|
|
337844
|
+
mountPath: vol.mountPath,
|
|
337845
|
+
readOnly: vol.readOnly
|
|
337846
|
+
});
|
|
337847
|
+
volumes.push({
|
|
337848
|
+
name: vol.name,
|
|
337849
|
+
persistentVolumeClaim: {
|
|
337850
|
+
claimName: `${config2.name}-${vol.name}`
|
|
337851
|
+
}
|
|
337852
|
+
});
|
|
337853
337853
|
}
|
|
337854
|
+
return { pvcs, volumeMounts, volumes };
|
|
337855
|
+
}
|
|
337856
|
+
function buildHealthProbes(config2) {
|
|
337854
337857
|
const healthCheck = config2.healthCheck;
|
|
337855
|
-
|
|
337856
|
-
|
|
337857
|
-
if (healthCheck) {
|
|
337858
|
-
const probeConfig = {
|
|
337859
|
-
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
337860
|
-
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
337861
|
-
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
337862
|
-
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
337863
|
-
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
337864
|
-
};
|
|
337865
|
-
if (healthCheck.httpPath) {
|
|
337866
|
-
const httpGet = {
|
|
337867
|
-
path: healthCheck.httpPath,
|
|
337868
|
-
port: healthCheck.port ?? config2.containerPort
|
|
337869
|
-
};
|
|
337870
|
-
livenessProbe = { ...probeConfig, httpGet };
|
|
337871
|
-
readinessProbe = { ...probeConfig, httpGet };
|
|
337872
|
-
} else {
|
|
337873
|
-
const tcpSocket = {
|
|
337874
|
-
port: healthCheck.port ?? config2.containerPort
|
|
337875
|
-
};
|
|
337876
|
-
livenessProbe = { ...probeConfig, tcpSocket };
|
|
337877
|
-
readinessProbe = { ...probeConfig, tcpSocket };
|
|
337878
|
-
}
|
|
337858
|
+
if (!healthCheck) {
|
|
337859
|
+
return {};
|
|
337879
337860
|
}
|
|
337880
|
-
const
|
|
337881
|
-
|
|
337861
|
+
const probeConfig = {
|
|
337862
|
+
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
337863
|
+
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
337864
|
+
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
337865
|
+
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
337866
|
+
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
337867
|
+
};
|
|
337868
|
+
if (healthCheck.httpPath) {
|
|
337869
|
+
const httpGet = {
|
|
337870
|
+
path: healthCheck.httpPath,
|
|
337871
|
+
port: healthCheck.port ?? config2.containerPort
|
|
337872
|
+
};
|
|
337873
|
+
return {
|
|
337874
|
+
livenessProbe: { ...probeConfig, httpGet },
|
|
337875
|
+
readinessProbe: { ...probeConfig, httpGet }
|
|
337876
|
+
};
|
|
337877
|
+
}
|
|
337878
|
+
const tcpSocket = { port: healthCheck.port ?? config2.containerPort };
|
|
337879
|
+
return {
|
|
337880
|
+
livenessProbe: { ...probeConfig, tcpSocket },
|
|
337881
|
+
readinessProbe: { ...probeConfig, tcpSocket }
|
|
337882
|
+
};
|
|
337883
|
+
}
|
|
337884
|
+
function buildContainerPorts(config2) {
|
|
337885
|
+
const ports = [
|
|
337882
337886
|
{ containerPort: config2.containerPort, name: "http" }
|
|
337883
337887
|
];
|
|
337884
337888
|
if (config2.additionalPorts) {
|
|
337885
337889
|
for (const port of config2.additionalPorts) {
|
|
337886
|
-
|
|
337890
|
+
ports.push({
|
|
337887
337891
|
containerPort: port.targetPort ?? port.port,
|
|
337888
337892
|
name: port.name,
|
|
337889
337893
|
protocol: port.protocol ?? "TCP"
|
|
337890
337894
|
});
|
|
337891
337895
|
}
|
|
337892
337896
|
}
|
|
337897
|
+
return ports;
|
|
337898
|
+
}
|
|
337899
|
+
function buildServicePorts(config2) {
|
|
337900
|
+
const ports = [
|
|
337901
|
+
{
|
|
337902
|
+
name: "http",
|
|
337903
|
+
port: config2.containerPort,
|
|
337904
|
+
targetPort: config2.containerPort,
|
|
337905
|
+
protocol: "TCP"
|
|
337906
|
+
}
|
|
337907
|
+
];
|
|
337908
|
+
if (config2.additionalPorts) {
|
|
337909
|
+
for (const port of config2.additionalPorts) {
|
|
337910
|
+
ports.push({
|
|
337911
|
+
name: port.name,
|
|
337912
|
+
port: port.port,
|
|
337913
|
+
targetPort: port.targetPort ?? port.port,
|
|
337914
|
+
protocol: port.protocol ?? "TCP"
|
|
337915
|
+
});
|
|
337916
|
+
}
|
|
337917
|
+
}
|
|
337918
|
+
return ports;
|
|
337919
|
+
}
|
|
337920
|
+
function createServiceIngress(provider, namespace, config2, labels, service) {
|
|
337921
|
+
if (!config2.ingress) {
|
|
337922
|
+
return;
|
|
337923
|
+
}
|
|
337924
|
+
const ingressAnnotations = {
|
|
337925
|
+
"kubernetes.io/ingress.class": "nginx",
|
|
337926
|
+
...config2.ingress.annotations
|
|
337927
|
+
};
|
|
337928
|
+
if (config2.ingress.tls?.enabled) {
|
|
337929
|
+
ingressAnnotations["cert-manager.io/cluster-issuer"] = config2.ingress.tls.issuerName ?? "letsencrypt-production";
|
|
337930
|
+
}
|
|
337931
|
+
let ingressPath = config2.ingress.path;
|
|
337932
|
+
let ingressPathType = config2.ingress.pathType ?? "Prefix";
|
|
337933
|
+
const shouldStripPrefix = config2.ingress.path !== "/" && !config2.ingress.keepPrefix;
|
|
337934
|
+
if (shouldStripPrefix) {
|
|
337935
|
+
ingressPath = `${config2.ingress.path}(/|$)(.*)`;
|
|
337936
|
+
ingressPathType = "ImplementationSpecific";
|
|
337937
|
+
ingressAnnotations["nginx.ingress.kubernetes.io/use-regex"] = "true";
|
|
337938
|
+
ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$2";
|
|
337939
|
+
}
|
|
337940
|
+
const createRule = (host) => ({
|
|
337941
|
+
...host && { host },
|
|
337942
|
+
http: {
|
|
337943
|
+
paths: [
|
|
337944
|
+
{
|
|
337945
|
+
path: ingressPath,
|
|
337946
|
+
pathType: ingressPathType,
|
|
337947
|
+
backend: {
|
|
337948
|
+
service: {
|
|
337949
|
+
name: config2.name,
|
|
337950
|
+
port: { number: config2.containerPort }
|
|
337951
|
+
}
|
|
337952
|
+
}
|
|
337953
|
+
}
|
|
337954
|
+
]
|
|
337955
|
+
}
|
|
337956
|
+
});
|
|
337957
|
+
const ingressRules = [];
|
|
337958
|
+
if (config2.ingress.host) {
|
|
337959
|
+
ingressRules.push(createRule(config2.ingress.host));
|
|
337960
|
+
} else {
|
|
337961
|
+
ingressRules.push(createRule());
|
|
337962
|
+
}
|
|
337963
|
+
if (config2.ingress.additionalHosts) {
|
|
337964
|
+
for (const additionalHost of config2.ingress.additionalHosts) {
|
|
337965
|
+
ingressRules.push(createRule(additionalHost));
|
|
337966
|
+
}
|
|
337967
|
+
}
|
|
337968
|
+
const allHosts = [
|
|
337969
|
+
...config2.ingress.host ? [config2.ingress.host] : [],
|
|
337970
|
+
...config2.ingress.additionalHosts ?? []
|
|
337971
|
+
];
|
|
337972
|
+
const tlsSecretName = config2.ingress.tls?.secretName ?? `${config2.name}-tls`;
|
|
337973
|
+
return new k8s5.networking.v1.Ingress(`${config2.name}-ingress`, {
|
|
337974
|
+
metadata: {
|
|
337975
|
+
name: config2.name,
|
|
337976
|
+
namespace,
|
|
337977
|
+
labels,
|
|
337978
|
+
annotations: ingressAnnotations
|
|
337979
|
+
},
|
|
337980
|
+
spec: {
|
|
337981
|
+
...config2.ingress.tls?.enabled && allHosts.length > 0 && {
|
|
337982
|
+
tls: [{ hosts: allHosts, secretName: tlsSecretName }]
|
|
337983
|
+
},
|
|
337984
|
+
rules: ingressRules
|
|
337985
|
+
}
|
|
337986
|
+
}, { provider, dependsOn: [service] });
|
|
337987
|
+
}
|
|
337988
|
+
function deployK8sService(provider, namespace, config2) {
|
|
337989
|
+
if (!config2.image) {
|
|
337990
|
+
throw new Error(`Missing "image" for service "${config2.name}". Either specify image explicitly or use discoverServiceConfigs() which auto-generates it from pf.registry.`);
|
|
337991
|
+
}
|
|
337992
|
+
const labels = buildLabels(config2.name, config2.labels);
|
|
337993
|
+
const replicas = config2.replicas ?? DEFAULTS.replicas;
|
|
337994
|
+
const imagePullPolicy = getImagePullPolicy(config2.image, config2.imagePullPolicy);
|
|
337995
|
+
const resources = config2.resources ?? DEFAULTS.resources;
|
|
337996
|
+
const secret = createServiceSecret(provider, namespace, config2, labels);
|
|
337997
|
+
const envVars = buildEnvVars(config2);
|
|
337998
|
+
const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, config2, labels);
|
|
337999
|
+
const { livenessProbe, readinessProbe } = buildHealthProbes(config2);
|
|
338000
|
+
const containerPorts = buildContainerPorts(config2);
|
|
338001
|
+
const servicePorts = buildServicePorts(config2);
|
|
337893
338002
|
const deployment = new k8s5.apps.v1.Deployment(`${config2.name}-deployment`, {
|
|
337894
338003
|
metadata: {
|
|
337895
338004
|
name: config2.name,
|
|
@@ -337931,24 +338040,6 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337931
338040
|
}
|
|
337932
338041
|
}
|
|
337933
338042
|
}, { provider, dependsOn: pvcs.length > 0 ? pvcs : undefined });
|
|
337934
|
-
const servicePorts = [
|
|
337935
|
-
{
|
|
337936
|
-
name: "http",
|
|
337937
|
-
port: config2.containerPort,
|
|
337938
|
-
targetPort: config2.containerPort,
|
|
337939
|
-
protocol: "TCP"
|
|
337940
|
-
}
|
|
337941
|
-
];
|
|
337942
|
-
if (config2.additionalPorts) {
|
|
337943
|
-
for (const port of config2.additionalPorts) {
|
|
337944
|
-
servicePorts.push({
|
|
337945
|
-
name: port.name,
|
|
337946
|
-
port: port.port,
|
|
337947
|
-
targetPort: port.targetPort ?? port.port,
|
|
337948
|
-
protocol: port.protocol ?? "TCP"
|
|
337949
|
-
});
|
|
337950
|
-
}
|
|
337951
|
-
}
|
|
337952
338043
|
const service = new k8s5.core.v1.Service(`${config2.name}-service`, {
|
|
337953
338044
|
metadata: {
|
|
337954
338045
|
name: config2.name,
|
|
@@ -337961,77 +338052,7 @@ function deployK8sService(provider, namespace, config2) {
|
|
|
337961
338052
|
ports: servicePorts
|
|
337962
338053
|
}
|
|
337963
338054
|
}, { provider, dependsOn: [deployment] });
|
|
337964
|
-
|
|
337965
|
-
if (config2.ingress) {
|
|
337966
|
-
const ingressAnnotations = {
|
|
337967
|
-
"kubernetes.io/ingress.class": "nginx",
|
|
337968
|
-
...config2.ingress.annotations
|
|
337969
|
-
};
|
|
337970
|
-
if (config2.ingress.tls?.enabled) {
|
|
337971
|
-
ingressAnnotations["cert-manager.io/cluster-issuer"] = config2.ingress.tls.issuerName ?? "letsencrypt-production";
|
|
337972
|
-
}
|
|
337973
|
-
let ingressPath = config2.ingress.path;
|
|
337974
|
-
let ingressPathType = config2.ingress.pathType ?? "Prefix";
|
|
337975
|
-
const shouldStripPrefix = config2.ingress.path !== "/" && !config2.ingress.keepPrefix;
|
|
337976
|
-
if (shouldStripPrefix) {
|
|
337977
|
-
ingressPath = `${config2.ingress.path}(/|$)(.*)`;
|
|
337978
|
-
ingressPathType = "ImplementationSpecific";
|
|
337979
|
-
ingressAnnotations["nginx.ingress.kubernetes.io/use-regex"] = "true";
|
|
337980
|
-
ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$2";
|
|
337981
|
-
}
|
|
337982
|
-
const tlsSecretName = config2.ingress.tls?.secretName ?? `${config2.name}-tls`;
|
|
337983
|
-
const ingressRules = [];
|
|
337984
|
-
const createRule = (host) => ({
|
|
337985
|
-
...host && { host },
|
|
337986
|
-
http: {
|
|
337987
|
-
paths: [
|
|
337988
|
-
{
|
|
337989
|
-
path: ingressPath,
|
|
337990
|
-
pathType: ingressPathType,
|
|
337991
|
-
backend: {
|
|
337992
|
-
service: {
|
|
337993
|
-
name: config2.name,
|
|
337994
|
-
port: { number: config2.containerPort }
|
|
337995
|
-
}
|
|
337996
|
-
}
|
|
337997
|
-
}
|
|
337998
|
-
]
|
|
337999
|
-
}
|
|
338000
|
-
});
|
|
338001
|
-
if (config2.ingress.host) {
|
|
338002
|
-
ingressRules.push(createRule(config2.ingress.host));
|
|
338003
|
-
} else {
|
|
338004
|
-
ingressRules.push(createRule());
|
|
338005
|
-
}
|
|
338006
|
-
if (config2.ingress.additionalHosts) {
|
|
338007
|
-
for (const additionalHost of config2.ingress.additionalHosts) {
|
|
338008
|
-
ingressRules.push(createRule(additionalHost));
|
|
338009
|
-
}
|
|
338010
|
-
}
|
|
338011
|
-
const allHosts = [
|
|
338012
|
-
...config2.ingress.host ? [config2.ingress.host] : [],
|
|
338013
|
-
...config2.ingress.additionalHosts ?? []
|
|
338014
|
-
];
|
|
338015
|
-
ingress = new k8s5.networking.v1.Ingress(`${config2.name}-ingress`, {
|
|
338016
|
-
metadata: {
|
|
338017
|
-
name: config2.name,
|
|
338018
|
-
namespace,
|
|
338019
|
-
labels,
|
|
338020
|
-
annotations: ingressAnnotations
|
|
338021
|
-
},
|
|
338022
|
-
spec: {
|
|
338023
|
-
...config2.ingress.tls?.enabled && allHosts.length > 0 && {
|
|
338024
|
-
tls: [
|
|
338025
|
-
{
|
|
338026
|
-
hosts: allHosts,
|
|
338027
|
-
secretName: tlsSecretName
|
|
338028
|
-
}
|
|
338029
|
-
]
|
|
338030
|
-
},
|
|
338031
|
-
rules: ingressRules
|
|
338032
|
-
}
|
|
338033
|
-
}, { provider, dependsOn: [service] });
|
|
338034
|
-
}
|
|
338055
|
+
const ingress = createServiceIngress(provider, namespace, config2, labels, service);
|
|
338035
338056
|
const serviceDns = `${config2.name}.${namespace}.svc.cluster.local`;
|
|
338036
338057
|
const internalUrl = pulumi6.output(`http://${serviceDns}:${config2.containerPort}`);
|
|
338037
338058
|
return {
|