Skip to content

Instantly share code, notes, and snippets.

@Duologic
Created December 12, 2023 11:32
Show Gist options
  • Save Duologic/67216c772a99cddd14a47b67d4eafa2d to your computer and use it in GitHub Desktop.
Save Duologic/67216c772a99cddd14a47b67d4eafa2d to your computer and use it in GitHub Desktop.
local k = import 'ksonnet-util/kausal.libsonnet';
{
new(status='404', name='return', image='httpd:2.4-alpine'):: {
local configMap = k.core.v1.configMap,
configmap:
configMap.new('%s-%s' % [name, status], {
'httpd.conf': |||
ServerRoot "/usr/local/apache2"
Listen 80
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule dir_module modules/mod_dir.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule alias_module modules/mod_alias.so
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Redirect %s /
AllowOverride None
Require all granted
</Directory>
||| % status,
}),
local container = k.core.v1.container,
local containerPort = k.core.v1.containerPort,
container::
container.new('httpd', image)
+ container.withPorts([
containerPort.newNamed(name='http', containerPort=80),
]),
local deployment = k.apps.v1.deployment,
deployment:
deployment.new('%s-%s' % [name, status], replicas=1, containers=[self.container])
+ deployment.emptyVolumeMount('htdocs', '/usr/local/apache2/htdocs')
+ deployment.configMapVolumeMount(self.configmap, '/usr/local/apache2/conf'),
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment