Skip to content

Commit

Permalink
feat(Matomo): add container probes
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Miglinci <pmig@glasskube.eu>
  • Loading branch information
pmig committed Sep 8, 2023
1 parent 87cf843 commit 6b4db59
Showing 1 changed file with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ import eu.glasskube.kubernetes.api.model.configMapRef
import eu.glasskube.kubernetes.api.model.container
import eu.glasskube.kubernetes.api.model.containerPort
import eu.glasskube.kubernetes.api.model.envFrom
import eu.glasskube.kubernetes.api.model.httpGet
import eu.glasskube.kubernetes.api.model.intOrString
import eu.glasskube.kubernetes.api.model.item
import eu.glasskube.kubernetes.api.model.items
import eu.glasskube.kubernetes.api.model.livenessProbe
import eu.glasskube.kubernetes.api.model.metadata
import eu.glasskube.kubernetes.api.model.persistentVolumeClaim
import eu.glasskube.kubernetes.api.model.readinessProbe
import eu.glasskube.kubernetes.api.model.secret
import eu.glasskube.kubernetes.api.model.secretRef
import eu.glasskube.kubernetes.api.model.spec
import eu.glasskube.kubernetes.api.model.startupProbe
import eu.glasskube.kubernetes.api.model.volume
import eu.glasskube.kubernetes.api.model.volumeMount
import eu.glasskube.kubernetes.api.model.volumeMounts
Expand Down Expand Up @@ -50,6 +55,7 @@ class MatomoDeployment : CRUDKubernetesDependentResource<Deployment, Matomo>(Dep
const val installShPath = "$scriptsDir/$installSh"
const val installJson = "install.json"
const val installJsonPath = "$configDir/$installJson"
private const val PROBE_PATH = "/matomo.php"
}

override fun desired(primary: Matomo, context: Context<Matomo>) = deployment {
Expand Down Expand Up @@ -129,7 +135,7 @@ class MatomoDeployment : CRUDKubernetesDependentResource<Deployment, Matomo>(Dep
container {
name = Matomo.APP_NAME
image = Matomo.APP_IMAGE
ports = listOf(containerPort { containerPort = 80 })
ports = listOf(containerPort { containerPort = 80; name = "http" })
resources = primary.spec.resources
envFrom {
secretRef(primary.databaseSecretName)
Expand All @@ -141,6 +147,37 @@ class MatomoDeployment : CRUDKubernetesDependentResource<Deployment, Matomo>(Dep
mountPath = htmlDir
}
}
startupProbe {
periodSeconds = 10
successThreshold = 1
// If the container is still unresponsive after 10 minutes, it will be restarted
failureThreshold = 60
httpGet {
path = PROBE_PATH
port = "http".intOrString()
}
}
livenessProbe {
periodSeconds = 10
successThreshold = 1
// If the container becomes unresponsive for 1 minute, it will be restarted
failureThreshold = 6
timeoutSeconds = 9
httpGet {
path = PROBE_PATH
port = "http".intOrString()
}
}
readinessProbe {
periodSeconds = 10
successThreshold = 1
failureThreshold = 3
timeoutSeconds = 9
httpGet {
path = PROBE_PATH
port = "http".intOrString()
}
}
}
)
volumes = listOf(
Expand Down

0 comments on commit 6b4db59

Please sign in to comment.