rpi.carlosedp.cluster-monit.../modules/smtp_relay.jsonnet

64 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

2019-08-08 22:09:53 +02:00
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
2019-02-04 20:24:49 +01:00
2019-02-27 13:28:00 +01:00
{
2019-02-04 20:24:49 +01:00
_config+:: {
namespace: 'monitoring',
2019-03-22 19:23:23 +01:00
versions+:: {
smtpRelay: 'v1.0.1',
2019-03-22 19:23:23 +01:00
},
imageRepos+:: {
smtpRelay: 'carlosedp/docker-smtp',
2019-03-22 19:23:23 +01:00
},
2019-02-04 20:24:49 +01:00
},
smtpRelay+:: {
2019-02-04 20:24:49 +01:00
deployment:
2019-10-09 16:26:42 +02:00
local deployment = k.apps.v1.deployment;
local container = k.apps.v1.deployment.mixin.spec.template.spec.containersType;
2019-02-04 20:24:49 +01:00
local containerPort = container.portsType;
local podLabels = { run: 'smtp-server' };
local smtpRelay =
container.new('smtp-server', $._config.imageRepos.smtpRelay + ':' + $._config.versions.smtpRelay) +
2019-08-09 00:39:08 +02:00
container.withPorts(containerPort.newNamed(25, 'smtp')) +
2019-02-04 20:24:49 +01:00
container.withEnv([
{
name: 'GMAIL_USER',
valueFrom: {
secretKeyRef: { name: 'smtp-account', key: 'username' },
},
},
{
name: 'GMAIL_PASSWORD',
valueFrom: {
secretKeyRef: { name: 'smtp-account', key: 'password' },
},
},
2019-03-13 22:44:01 +01:00
{
name: 'DISABLE_IPV6',
value: 'True',
},
{ name: 'RELAY_DOMAINS', value: ':192.168.0.0/24:10.0.0.0/16' },
2019-02-04 20:24:49 +01:00
]);
local c = [smtpRelay];
2019-02-04 20:24:49 +01:00
2019-03-13 22:44:01 +01:00
deployment.new('smtp-server', 1, c, podLabels) +
deployment.mixin.metadata.withNamespace($._config.namespace) +
deployment.mixin.metadata.withLabels(podLabels) +
deployment.mixin.spec.selector.withMatchLabels(podLabels),
2019-02-04 20:24:49 +01:00
service:
2019-03-13 22:44:01 +01:00
local service = k.core.v1.service;
local servicePort = k.core.v1.service.mixin.spec.portsType;
local smtpRelayPorts = servicePort.newNamed('smtp', 25, 'smtp');
2019-02-04 20:24:49 +01:00
service.new('smtp-server', $.smtpRelay.deployment.spec.selector.matchLabels, smtpRelayPorts) +
2019-03-13 22:44:01 +01:00
service.mixin.metadata.withNamespace($._config.namespace) +
service.mixin.metadata.withLabels({ run: 'smtp-server' }),
2019-02-04 20:24:49 +01:00
},
2019-03-13 22:44:01 +01:00
}