Skip to content

Commit d880bb1

Browse files
Add workshop demo of how to add cookie consent theme.
1 parent 9ae1f16 commit d880bb1

File tree

7 files changed

+394
-0
lines changed

7 files changed

+394
-0
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cookie Consent
2+
3+
Overview of embedding cookie consent.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
apiVersion: training.educates.dev/v1beta1
2+
kind: Workshop
3+
metadata:
4+
name: "lab-cookie-consent"
5+
spec:
6+
title: "Cookie Consent"
7+
description: "Overview of embedding cookie consent."
8+
publish:
9+
image: $(image_repository)/labs-educates-showcase/lab-cookie-consent-files:$(workshop_version)
10+
workshop:
11+
files:
12+
- image:
13+
url: "$(image_repository)/labs-educates-showcase/lab-cookie-consent-files:$(workshop_version)"
14+
includePaths:
15+
- /workshop/**
16+
- /exercises/**
17+
- /README.md
18+
packages:
19+
- name: educates
20+
files:
21+
- image:
22+
url: $(oci_image_cache)/educates-client-programs:installer-clean
23+
path: bin
24+
includePaths:
25+
- educates-linux-$(platform_arch)
26+
session:
27+
namespaces:
28+
budget: x-large
29+
security:
30+
policy: baseline
31+
token:
32+
enabled: false
33+
applications:
34+
terminal:
35+
enabled: true
36+
layout: split
37+
editor:
38+
enabled: true
39+
console:
40+
enabled: false
41+
docker:
42+
enabled: true
43+
socket:
44+
enabled: false
45+
compose:
46+
services:
47+
registry:
48+
image: registry:2.8.3
49+
ports:
50+
- "0.0.0.0:5001:5000"
51+
registry:
52+
enabled: false
53+
vcluster:
54+
enabled: false
55+
volumes:
56+
- name: admin-credentials-config
57+
secret:
58+
secretName: $(session_name)-kubeconfig
59+
volumeMounts:
60+
- name: admin-credentials-config
61+
mountPath: /opt/kubeconfig
62+
objects:
63+
- apiVersion: v1
64+
kind: Secret
65+
metadata:
66+
name: $(session_name)-admin-vcluster-values
67+
namespace: $(workshop_namespace)
68+
stringData:
69+
values.yaml: |
70+
vcluster:
71+
image: rancher/k3s:v1.25.3-k3s1
72+
syncer:
73+
extraArgs:
74+
- --tls-san=admin-vcluster.$(session_namespace).svc.$(cluster_domain)
75+
- --out-kube-config-server=https://admin-vcluster.$(session_namespace).svc.$(cluster_domain)
76+
mapServices:
77+
fromHost:
78+
- from: $(workshop_namespace)/registry-$(session_name)
79+
to: default/registry
80+
- from: $(workshop_namespace)/localhost-$(session_name)
81+
to: default/loopback
82+
sync:
83+
ingresses:
84+
enabled: true
85+
- apiVersion: kappctrl.k14s.io/v1alpha1
86+
kind: App
87+
metadata:
88+
name: $(session_name)-admin-vcluster-package
89+
namespace: $(workshop_namespace)
90+
spec:
91+
serviceAccountName: kapp-installer
92+
syncPeriod: 720h
93+
noopDelete: true
94+
fetch:
95+
- helmChart:
96+
name: vcluster
97+
repository:
98+
url: https://charts.loft.sh
99+
template:
100+
- helmTemplate:
101+
name: admin-vcluster
102+
namespace: $(session_namespace)
103+
valuesFrom:
104+
- secretRef:
105+
name: $(session_name)-admin-vcluster-values
106+
- ytt:
107+
inline:
108+
paths:
109+
overlays.yaml: |
110+
#@ load("@ytt:data", "data")
111+
#@ load("@ytt:overlay", "overlay")
112+
#@overlay/match by=overlay.all, expects="1+"
113+
---
114+
metadata:
115+
#@overlay/match missing_ok=True
116+
ownerReferences:
117+
- apiVersion: training.educates.dev/v1beta1
118+
kind: WorkshopSession
119+
blockOwnerDeletion: true
120+
controller: true
121+
name: $(session_name)
122+
uid: $(workshop_session_uid)
123+
deploy:
124+
- kapp:
125+
rawOptions:
126+
- --app-changes-max-to-keep=5
127+
- apiVersion: secrets.educates.dev/v1beta1
128+
kind: SecretCopier
129+
metadata:
130+
name: $(session_name)-kubeconfig
131+
spec:
132+
rules:
133+
- sourceSecret:
134+
name: vc-admin-vcluster
135+
namespace: $(session_namespace)
136+
targetNamespaces:
137+
nameSelector:
138+
matchNames:
139+
- $(workshop_namespace)
140+
targetSecret:
141+
name: $(session_name)-kubeconfig
142+
- apiVersion: v1
143+
kind: Service
144+
metadata:
145+
name: registry-$(session_name)
146+
namespace: $(workshop_namespace)
147+
spec:
148+
type: ClusterIP
149+
selector:
150+
deployment: $(session_name)
151+
ports:
152+
- name: registry
153+
port: 80
154+
protocol: TCP
155+
targetPort: 5001
156+
- apiVersion: v1
157+
kind: Service
158+
metadata:
159+
name: localhost-$(session_name)
160+
namespace: $(workshop_namespace)
161+
spec:
162+
type: ClusterIP
163+
selector:
164+
deployment: $(session_name)
165+
ports:
166+
- name: renderer
167+
port: 10081
168+
protocol: TCP
169+
targetPort: 10081
170+
environment:
171+
images:
172+
registries:
173+
- content:
174+
- destination: /educates-client-programs
175+
prefix: /jorgemoralespou/educates-client-programs
176+
stripPrefix: true
177+
onDemand: true
178+
urls:
179+
- https://ghcr.io
180+
objects:
181+
- apiVersion: v1
182+
kind: ServiceAccount
183+
metadata:
184+
name: kapp-installer
185+
- apiVersion: rbac.authorization.k8s.io/v1
186+
kind: ClusterRoleBinding
187+
metadata:
188+
name: kapp-installer-$(workshop_namespace)
189+
roleRef:
190+
apiGroup: rbac.authorization.k8s.io
191+
kind: ClusterRole
192+
name: cluster-admin
193+
subjects:
194+
- kind: ServiceAccount
195+
name: kapp-installer
196+
namespace: $(workshop_namespace)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# pathways:
2+
# default: workshop
3+
#
4+
# paths:
5+
# workshop:
6+
# title: "Workshop"
7+
#
8+
# steps:
9+
# - 00-workshop-overview
10+
# - 01-workshop-instructions
11+
# - 99-workshop-summary
12+
#
13+
# params:
14+
# - name: NAME
15+
# value: undefined
16+
# aliases:
17+
# - ALIAS
18+
19+
# modules:
20+
# - name: 00-workshop-overview
21+
# title: Workshop Overview
22+
# - name: 01-workshop-instructions
23+
# title: Workshop Instructions
24+
# - name: 99-workshop-summary
25+
# title: Workshop Summary
26+
27+
# params:
28+
# - name: NAME
29+
# value: undefined
30+
# aliases:
31+
# - ALIAS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
title: Workshop Overview
3+
---
4+
5+
Note that once `vcluster` provider config added to CLI as one of the set of opinionated configs, this can be simplified.
6+
7+
Download Javascript and CSS files for CookieConsent package from the CDN.
8+
9+
```terminal:execute
10+
command: curl -L -o cookieconsent.css https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.css
11+
```
12+
13+
```terminal:execute
14+
command: curl -L -o cookieconsent.umd.js https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.umd.js
15+
```
16+
17+
Create `.css` and `.js` files for the training portal.
18+
19+
```terminal:execute
20+
command: cat cookieconsent.css > training-portal.css
21+
```
22+
23+
```terminal:execute
24+
command: cat cookieconsent.umd.js > training-portal.js
25+
```
26+
27+
```terminal:execute
28+
command: |
29+
cat << EOF >> training-portal.js
30+
/**
31+
* All config. options available here:
32+
* https://cookieconsent.orestbida.com/reference/configuration-reference.html
33+
*/
34+
CookieConsent.run({
35+
36+
categories: {
37+
necessary: {
38+
enabled: true, // this category is enabled by default
39+
readOnly: true // this category cannot be disabled
40+
},
41+
analytics: {}
42+
},
43+
44+
language: {
45+
default: 'en',
46+
translations: {
47+
en: {
48+
consentModal: {
49+
title: 'We use cookies',
50+
description: 'Cookie modal description',
51+
acceptAllBtn: 'Accept all',
52+
acceptNecessaryBtn: 'Reject all',
53+
showPreferencesBtn: 'Manage Individual preferences'
54+
},
55+
preferencesModal: {
56+
title: 'Manage cookie preferences',
57+
acceptAllBtn: 'Accept all',
58+
acceptNecessaryBtn: 'Reject all',
59+
savePreferencesBtn: 'Accept current selection',
60+
closeIconLabel: 'Close modal',
61+
sections: [
62+
{
63+
title: 'Somebody said ... cookies?',
64+
description: 'I want one!'
65+
},
66+
{
67+
title: 'Strictly Necessary cookies',
68+
description: 'These cookies are essential for the proper functioning of the website and cannot be disabled.',
69+
70+
//this field will generate a toggle linked to the 'necessary' category
71+
linkedCategory: 'necessary'
72+
},
73+
{
74+
title: 'Performance and Analytics',
75+
description: 'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.',
76+
linkedCategory: 'analytics'
77+
},
78+
{
79+
title: 'More information',
80+
description: 'For any queries in relation to my policy on cookies and your choices, please <a href="#contact-page">contact us</a>'
81+
}
82+
]
83+
}
84+
}
85+
}
86+
}
87+
});
88+
EOF
89+
```
90+
91+
Create a Kubernetes secret using these as theme files.
92+
93+
```terminal:execute
94+
command: kubectl create ns educates-themes
95+
```
96+
97+
```terminal:execute
98+
command: kubectl create secret generic cookieconsent-theme -n educates-themes --from-file=training-portal.css --from-file=training-portal.js
99+
```
100+
101+
```editor:append-lines-to-file
102+
file: ~/config.yaml
103+
text: |
104+
clusterInfrastructure:
105+
provider: custom
106+
107+
clusterPackages:
108+
contour:
109+
enabled: false
110+
kyverno:
111+
enabled: false
112+
113+
clusterIngress:
114+
domain: {{< param session_name >}}.{{< param ingress_domain >}}
115+
116+
clusterSecurity:
117+
policyEngine: none
118+
119+
workshopSecurity:
120+
rulesEngine: none
121+
122+
imageRegistry:
123+
host: registry.default.svc.cluster.local
124+
125+
imagePuller:
126+
enabled: false
127+
128+
websiteStyling:
129+
defaultTheme: cookieconsent-theme
130+
themeDataRefs:
131+
- name: cookieconsent-theme
132+
namespace: educates-themes
133+
```
134+
135+
```terminal:execute
136+
command: educates admin cluster install --config config.yaml
137+
```
138+
139+
```terminal:execute
140+
command: educates deploy-workshop -f https://github.com/vmware-tanzu-labs/lab-k8s-fundamentals/releases/latest/download/workshop.yaml
141+
```
142+
143+
```terminal:execute
144+
command: educates browse-workshops
145+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Workshop Instructions
3+
---
4+
5+
This is the first page of the workshop instructions, create as many separate pages as you need to. If necessary pages can be located in sub directories to provided grouping.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Workshop Summary
3+
---
4+
5+
This is the last page of the workshop. Include in this page a summary of the workshop and any links to resources relevant to the workshop. This ensures anyone doing the workshop has material they can research later to learn more.

0 commit comments

Comments
 (0)