forked from hswaw/hscloud
108 lines
3.6 KiB
Plaintext
108 lines
3.6 KiB
Plaintext
local kube = import "../../../kube/hscloud.libsonnet";
|
|
|
|
{
|
|
local top = self,
|
|
local cfg = self.cfg,
|
|
|
|
cfg:: {
|
|
name: "wordpress",
|
|
namespace: "personal-radex",
|
|
domain: "wordpress.hs.radex.io",
|
|
|
|
storageClassName: "waw-hdd-redundant-3",
|
|
storageSize: "5Gi",
|
|
},
|
|
|
|
secretRefs:: {
|
|
mysql: { secretKeyRef: { name: cfg.name, key: 'mysql_password' } },
|
|
wordpress: { secretKeyRef: { name: cfg.name, key: 'wordpress_password' } },
|
|
},
|
|
|
|
local ns = kube.Namespace(cfg.namespace),
|
|
|
|
deployment: ns.Contain(kube.Deployment(cfg.name)) {
|
|
spec+: {
|
|
replicas: 1,
|
|
template+: {
|
|
spec+: {
|
|
containers_: {
|
|
default: kube.Container("default") {
|
|
image: 'bitnami/wordpress',
|
|
resources: {
|
|
requests: { cpu: "50m", memory: "128M" },
|
|
limits: { cpu: "750m", memory: "256M" },
|
|
},
|
|
ports_: {
|
|
http: { containerPort: 8080 },
|
|
},
|
|
env_: {
|
|
WORDPRESS_DATABASE_HOST: 'wordpress-mysql',
|
|
WORDPRESS_DATABASE_NAME: 'wordpress',
|
|
WORDPRESS_DATABASE_USER: 'wordpress',
|
|
WORDPRESS_DATABASE_PASSWORD: top.secretRefs.mysql,
|
|
WORDPRESS_USERNAME: 'admin',
|
|
WORDPRESS_PASSWORD: top.secretRefs.wordpress,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
service: ns.Contain(kube.Service(cfg.name)) {
|
|
target:: top.deployment,
|
|
},
|
|
|
|
ingress: ns.Contain(kube.SimpleIngress(cfg.name)) {
|
|
hosts:: [cfg.domain],
|
|
target_service:: top.service,
|
|
},
|
|
|
|
mysql: {
|
|
local mysql = self,
|
|
|
|
volume: ns.Contain(kube.PersistentVolumeClaim("wordpress-mysql")) {
|
|
storage:: cfg.storageSize,
|
|
storageClass:: cfg.storageClassName,
|
|
},
|
|
|
|
deployment: ns.Contain(kube.Deployment("wordpress-mysql")) {
|
|
spec+: {
|
|
replicas: 1,
|
|
template+: {
|
|
spec+: {
|
|
volumes_: {
|
|
data: kube.PersistentVolumeClaimVolume(mysql.volume),
|
|
},
|
|
containers_: {
|
|
default: kube.Container("default") {
|
|
image: "mysql:8.2.0",
|
|
ports_: {
|
|
client: { containerPort: 3306 },
|
|
},
|
|
env_: {
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "yes",
|
|
MYSQL_DATABASE: "wordpress",
|
|
MYSQL_USER: "wordpress",
|
|
MYSQL_PASSWORD: top.secretRefs.mysql,
|
|
},
|
|
volumeMounts_: {
|
|
data: { mountPath: '/var/lib/mysql' },
|
|
},
|
|
}
|
|
},
|
|
securityContext: {
|
|
runAsUser: 999,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
service: ns.Contain(kube.Service("wordpress-mysql")) {
|
|
target:: mysql.deployment,
|
|
},
|
|
},
|
|
}
|