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

Commit ce643b1

Browse files
authored
Merge pull request #67 from jetstack/add-landing-page
Add landing page
2 parents 7d16230 + 8c749d8 commit ce643b1

File tree

6 files changed

+431
-1
lines changed

6 files changed

+431
-1
lines changed
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
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_TOP_LEVEL_PATH = '/etc/nginx/nginx.conf';
7+
local CONFIG_DEFAULT_PATH = '/etc/nginx/conf.d';
8+
local HTTP_PORT = 80;
9+
10+
{
11+
p:: '',
12+
13+
app:: 'landingpage',
14+
15+
index:: false,
16+
17+
name:: $.p + $.app,
18+
19+
domain:: 'example.net',
20+
21+
sslRedirectDomains:: ['redirect1.example.net', 'redirect2.example.net'],
22+
23+
namespace:: 'auth',
24+
25+
labels:: {
26+
metadata+: {
27+
labels+: {
28+
app: $.app,
29+
},
30+
},
31+
},
32+
33+
metadata:: $.labels {
34+
metadata+: {
35+
namespace: $.namespace,
36+
},
37+
},
38+
39+
redirectStatement:: if std.length($.sslRedirectDomains) > 0 then
40+
'server {\n' +
41+
' listen 80;\n' +
42+
' server_name ' + std.join(' ', $.sslRedirectDomains) + ';\n' +
43+
' return 301 https://$host$request_uri;\n' +
44+
'}\n'
45+
else
46+
'',
47+
48+
configMap: kube.ConfigMap($.name) + $.metadata {
49+
data+: {
50+
'nginx.conf': |||
51+
user nginx;
52+
worker_processes 1;
53+
54+
error_log /var/log/nginx/error.log warn;
55+
pid /var/run/nginx.pid;
56+
57+
58+
events {
59+
worker_connections 1024;
60+
}
61+
62+
63+
http {
64+
include /etc/nginx/mime.types;
65+
default_type application/octet-stream;
66+
67+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
68+
'$status $body_bytes_sent "$http_referer" '
69+
'"$http_user_agent" "$http_x_forwarded_for"';
70+
71+
access_log /var/log/nginx/access.log main;
72+
73+
sendfile on;
74+
75+
keepalive_timeout 65;
76+
77+
server_names_hash_bucket_size 256;
78+
79+
include /etc/nginx/conf.d/*.conf;
80+
}
81+
|||,
82+
'default.conf': |||
83+
server {
84+
listen 80;
85+
server_name _;
86+
87+
location / {
88+
root /usr/share/nginx/html;
89+
index index.html index.htm;
90+
}
91+
92+
error_page 500 502 503 504 /50x.html;
93+
location = /50x.html {
94+
root /usr/share/nginx/html;
95+
}
96+
if ($http_x_forwarded_proto = "http") {
97+
return 301 https://$host$request_uri;
98+
}
99+
}
100+
||| + $.redirectStatement,
101+
},
102+
},
103+
104+
Link(cloud, link, text):: std.manifestXmlJsonml([
105+
'div',
106+
{ class: 'col s12 m4' },
107+
'\n ',
108+
[
109+
'div',
110+
{},
111+
[
112+
'img',
113+
{
114+
width: 56,
115+
height: 56,
116+
alt: cloud,
117+
src: cloud + '.svg',
118+
},
119+
],
120+
],
121+
[
122+
'div',
123+
{},
124+
[
125+
'a',
126+
{
127+
class: 'btn-large waves-effect waves-light blue',
128+
href: link,
129+
},
130+
text,
131+
],
132+
],
133+
'\n',
134+
]),
135+
136+
content:: '',
137+
138+
wwwConfigMap: if $.index then kube.ConfigMap($.name + '-www') + $.metadata {
139+
data+: {
140+
'index.html': std.strReplace(
141+
(importstr './landingpage/index.html'),
142+
'#CONTENT#',
143+
$.content,
144+
),
145+
'amazon.svg': importstr './landingpage/amazon.svg',
146+
'google.svg': importstr './landingpage/google.svg',
147+
'digitalocean.svg': importstr './landingpage/digitalocean.svg',
148+
},
149+
},
150+
151+
deployment: kube.Deployment($.name) + $.metadata {
152+
local this = self,
153+
spec+: {
154+
replicas: 1,
155+
template+: {
156+
metadata+: {
157+
annotations+: {
158+
'config/hash': std.md5(std.escapeStringJson($.configMap)),
159+
} + if $.index then { 'www/hash': std.md5(std.escapeStringJson($.wwwConfigMap)) } else {},
160+
},
161+
spec+: {
162+
affinity: kube.PodZoneAntiAffinityAnnotation(this.spec.template),
163+
default_container: $.app,
164+
volumes_+: {
165+
config: kube.ConfigMapVolume($.configMap),
166+
} + if $.index then { www: kube.ConfigMapVolume($.wwwConfigMap) } else {},
167+
containers_+: {
168+
landingpage: kube.Container($.app) {
169+
local container = self,
170+
image: IMAGE,
171+
args: [
172+
'nginx',
173+
'-g',
174+
'daemon off;',
175+
'-c',
176+
CONFIG_TOP_LEVEL_PATH,
177+
],
178+
resources: {
179+
requests: { cpu: '10m', memory: '64Mi' },
180+
},
181+
ports_+: {
182+
http: { containerPort: HTTP_PORT },
183+
},
184+
volumeMounts_+: {
185+
config_top_level: { name: 'config', mountPath: CONFIG_TOP_LEVEL_PATH, subPath: 'nginx.conf' },
186+
config_default: { name: 'config', mountPath: CONFIG_DEFAULT_PATH + '/default.conf', subPath: 'default.conf' },
187+
} + if $.index then { www: { mountPath: WWW_VOLUME_PATH } } else {},
188+
readinessProbe: {
189+
httpGet: { path: '/', port: HTTP_PORT },
190+
},
191+
livenessProbe: self.readinessProbe {
192+
// elasticsearch_logging_discovery has a 5min timeout on cluster bootstrap
193+
initialDelaySeconds: 2 * 60,
194+
failureThreshold: 4,
195+
},
196+
},
197+
},
198+
},
199+
},
200+
},
201+
},
202+
203+
204+
ingress: if std.length($.sslRedirectDomains) > 0 || $.index then kube.Ingress($.name) + $.metadata {
205+
local hosts = $.sslRedirectDomains + if $.index then [$.domain] else [],
206+
metadata+: {
207+
annotations+: {
208+
'kubernetes.io/ingress.class': 'contour',
209+
},
210+
},
211+
spec+: {
212+
rules+: std.map(
213+
(function(h) {
214+
host: h,
215+
http: {
216+
paths: [
217+
{ path: '/', backend: $.svc.name_port },
218+
],
219+
},
220+
}), hosts
221+
),
222+
} + if $.index && $.certificate != null then {
223+
tls: [{
224+
hosts: [$.domain],
225+
secretName: $.certificate.spec.secretName,
226+
}],
227+
} else {},
228+
},
229+
230+
231+
svc: kube.Service($.name) + $.metadata {
232+
target_pod: $.deployment.spec.template,
233+
spec+: {
234+
sessionAffinity: 'None',
235+
},
236+
},
237+
}
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)