Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit d4d2a72

Browse files
committed
Add a nice landing page under $.basedomain
Signed-off-by: Christian Simon <[email protected]>
1 parent 7d16230 commit d4d2a72

File tree

6 files changed

+390
-1
lines changed

6 files changed

+390
-1
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
local kube = import '../vendor/kube-prod-runtime/lib/kube.libsonnet';
2+
local utils = import '../vendor/kube-prod-runtime/lib/utils.libsonnet';
3+
4+
local IMAGE = 'nginx:1.15.12';
5+
local WWW_VOLUME_PATH = '/usr/share/nginx/html';
6+
local CONFIG_PATH = '/etc/nginx/conf.d';
7+
local HTTP_PORT = 80;
8+
9+
{
10+
p:: '',
11+
12+
app:: 'landingpage',
13+
14+
index:: false,
15+
16+
name:: $.p + $.app,
17+
18+
domain:: 'example.net',
19+
20+
sslRedirectDomains:: ['redirect1.example.net', 'redirect2.example.net'],
21+
22+
namespace:: 'auth',
23+
24+
labels:: {
25+
metadata+: {
26+
labels+: {
27+
app: $.app,
28+
},
29+
},
30+
},
31+
32+
metadata:: $.labels {
33+
metadata+: {
34+
namespace: $.namespace,
35+
},
36+
},
37+
38+
redirectStatement:: if std.length($.sslRedirectDomains) > 0 then
39+
'server {\n' +
40+
' listen 80;\n' +
41+
' server_name ' + std.join(' ', $.sslRedirectDomains) + ';\n' +
42+
' return 301 https://$host$request_uri;\n' +
43+
'}\n'
44+
else
45+
'',
46+
47+
configMap: kube.ConfigMap($.name) + $.metadata {
48+
data+: {
49+
'default.conf': |||
50+
server {
51+
listen 80;
52+
server_name _;
53+
54+
location / {
55+
root /usr/share/nginx/html;
56+
index index.html index.htm;
57+
}
58+
59+
error_page 500 502 503 504 /50x.html;
60+
location = /50x.html {
61+
root /usr/share/nginx/html;
62+
}
63+
if ($http_x_forwarded_proto = "http") {
64+
return 301 https://$host$request_uri;
65+
}
66+
}
67+
||| + $.redirectStatement,
68+
},
69+
},
70+
71+
Link(cloud, link, text):: std.manifestXmlJsonml([
72+
'div',
73+
{ class: 'col s12 m4' },
74+
'\n ',
75+
[
76+
'div',
77+
{},
78+
[
79+
'img',
80+
{
81+
width: 56,
82+
height: 56,
83+
alt: cloud,
84+
src: cloud + '.svg',
85+
},
86+
],
87+
],
88+
[
89+
'div',
90+
{},
91+
[
92+
'a',
93+
{
94+
class: 'btn-large waves-effect waves-light blue',
95+
href: link,
96+
},
97+
text,
98+
],
99+
],
100+
'\n',
101+
]),
102+
103+
content:: '',
104+
105+
wwwConfigMap: if $.index then kube.ConfigMap($.name + '-www') + $.metadata {
106+
data+: {
107+
'index.html': std.strReplace(
108+
(importstr './landingpage/index.html'),
109+
'#CONTENT#',
110+
$.content,
111+
),
112+
'amazon.svg': importstr './landingpage/amazon.svg',
113+
'google.svg': importstr './landingpage/google.svg',
114+
'digitalocean.svg': importstr './landingpage/digitalocean.svg',
115+
},
116+
},
117+
118+
deployment: kube.Deployment($.name) + $.metadata {
119+
local this = self,
120+
spec+: {
121+
replicas: 1,
122+
template+: {
123+
metadata+: {
124+
annotations+: {
125+
'config/hash': std.md5(std.escapeStringJson($.configMap)),
126+
} + if $.index then { 'www/hash': std.md5(std.escapeStringJson($.wwwConfigMap)) } else {},
127+
},
128+
spec+: {
129+
affinity: kube.PodZoneAntiAffinityAnnotation(this.spec.template),
130+
default_container: $.app,
131+
volumes_+: {
132+
config: kube.ConfigMapVolume($.configMap),
133+
} + if $.index then { www: kube.ConfigMapVolume($.wwwConfigMap) } else {},
134+
containers_+: {
135+
landingpage: kube.Container($.app) {
136+
local container = self,
137+
image: IMAGE,
138+
resources: {
139+
requests: { cpu: '10m', memory: '64Mi' },
140+
},
141+
ports_+: {
142+
http: { containerPort: HTTP_PORT },
143+
},
144+
volumeMounts_+: {
145+
config: { mountPath: CONFIG_PATH },
146+
} + if $.index then { www: { mountPath: WWW_VOLUME_PATH } } else {},
147+
readinessProbe: {
148+
httpGet: { path: '/', port: HTTP_PORT },
149+
},
150+
livenessProbe: self.readinessProbe {
151+
// elasticsearch_logging_discovery has a 5min timeout on cluster bootstrap
152+
initialDelaySeconds: 2 * 60,
153+
failureThreshold: 4,
154+
},
155+
},
156+
},
157+
},
158+
},
159+
},
160+
},
161+
162+
163+
ingress: if std.length($.sslRedirectDomains) > 0 || $.index then kube.Ingress($.name) + $.metadata {
164+
local hosts = $.sslRedirectDomains + if $.index then [$.domain] else [],
165+
metadata+: {
166+
annotations+: {
167+
'kubernetes.io/ingress.class': 'contour',
168+
},
169+
},
170+
spec+: {
171+
rules+: std.map(
172+
(function(h) {
173+
host: h,
174+
http: {
175+
paths: [
176+
{ path: '/', backend: $.svc.name_port },
177+
],
178+
},
179+
}), hosts
180+
),
181+
} + if $.index && $.certificate != null then {
182+
tls: [{
183+
hosts: [$.domain],
184+
secretName: $.certificate.spec.secretName,
185+
}],
186+
} else {},
187+
},
188+
189+
190+
svc: kube.Service($.name) + $.metadata {
191+
target_pod: $.deployment.spec.template,
192+
spec+: {
193+
sessionAffinity: 'None',
194+
},
195+
},
196+
}
Lines changed: 15 additions & 0 deletions
Loading
Lines changed: 72 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
5+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
6+
<title>Kube-OIDC-Proxy</title>
7+
8+
<!-- CSS -->
9+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
11+
<style>
12+
pre.bash {
13+
background-color: black;
14+
color: #49fb35;
15+
font-size: small;
16+
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
17+
overflow: auto;
18+
word-wrap: normal;
19+
white-space: pre;
20+
}
21+
22+
.icon-block {
23+
padding: 0 15px;
24+
}
25+
.icon-block .material-icons {
26+
font-size: inherit;
27+
}
28+
</style>
29+
</head>
30+
<body>
31+
<nav class="light-blue blue" role="navigation">
32+
<div class="nav-wrapper container"><a id="logo-container" href="#" class="brand-logo">Kube-OIDC-Proxy Demo</a>
33+
<ul class="right hide-on-med-and-down">
34+
35+
</ul>
36+
37+
<ul id="nav-mobile" class="side-nav">
38+
39+
</ul>
40+
<a href="#" data-activates="nav-mobile" class="button-collapse"><i class="material-icons">menu</i></a>
41+
</div>
42+
</nav>
43+
<div class="section no-pad-bot" id="index-banner">
44+
<div class="container">
45+
<br><br>
46+
<h1 class="header center darken-3">Kube-OIDC-Proxy Demo</h1>
47+
<div class="row center">
48+
<h5 class="header col s12 light">This demo will help you to understand the use cases for <a href="https://github.com/jetstack/kube-oidc-proxy" target="_blank">kube-oidc-proxy</a>.</h5>
49+
</div>
50+
<div class="row center">
51+
#CONTENT#
52+
</div>
53+
<br><br>
54+
</div>
55+
</div>
56+
</body>
57+
</html>

0 commit comments

Comments
 (0)