Skip to content

Commit 906d179

Browse files
committed
provision a Gateway page improved
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
1 parent e48d082 commit 906d179

File tree

4 files changed

+117
-22
lines changed

4 files changed

+117
-22
lines changed

app/_how-tos/operator-get-started-gateway-api-provision-gateway.md renamed to app/_how-tos/operator-get-started-gateway-api-create-gateway.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,28 @@ search_aliases:
3030
- konnect hybrid gateway
3131

3232
tldr:
33-
q: How do I configure a Hybrid Gateway in {{site.konnect_short_name}}?
34-
a: Fill Konnect related fields in `GatewayConfiguration` for `GatewayClass` that will be used for Hybrid Gateways.
33+
q: How can I create a Gateway with {{ site.operator_product_name }} with self-managed Control Plane?
34+
a: Create a `GatewayConfiguration` object, then create a `GatewayClass` instance and a `Gateway` resource.
3535

3636
prereqs:
37-
skip_product: true
37+
skip_product: false
3838
operator:
3939
konnect:
4040
auth: true
4141

4242
---
4343

44-
## Create a `GatewayClass` for a Hybrid Gateway
44+
## Create a `GatewayConfiguration`
4545

46+
{: data-deployment-topology="konnect" }
4647
Use the `GatewayConfiguration` resource to configure a `GatewayClass` for Hybrid Gateways. `GatewayConfiguration` is for Hybrid Gateways when field `spec.konnect.authRef` is set.
4748

4849
<!-- vale off -->
4950
{% konnect_crd %}
5051
kind: GatewayConfiguration
5152
apiVersion: gateway-operator.konghq.com/v2beta1
5253
metadata:
53-
name: hybrid-configuration
54+
name: gateway-configuration
5455
namespace: kong
5556
spec:
5657
konnect:
@@ -66,49 +67,75 @@ spec:
6667
{% endkonnect_crd %}
6768
<!-- vale on -->
6869

69-
Next configure respective `GatewayClass` to use the above `GatewayConfiguration`.
70+
{: data-deployment-topology="on-prem" }
71+
Use the `GatewayConfiguration` resource to configure a `GatewayClass` for on-premise Gateways.
7072

7173
<!-- vale off -->
72-
{% konnect_crd %}
74+
{% on_prem_crd %}
75+
kind: GatewayConfiguration
76+
apiVersion: gateway-operator.konghq.com/v2beta1
77+
metadata:
78+
name: kong-configuration
79+
namespace: kong
80+
spec:
81+
dataPlaneOptions:
82+
deployment:
83+
podTemplateSpec:
84+
spec:
85+
containers:
86+
- name: proxy
87+
image: kong/kong-gateway:3.12
88+
{% endon_prem_crd %}
89+
<!-- vale on -->
90+
91+
## Create a `GatewayClass`
92+
93+
Next configure respective `GatewayClass` to use the above `GatewayConfiguration`.
94+
95+
```yaml
7396
kind: GatewayClass
7497
apiVersion: gateway.networking.k8s.io/v1
7598
metadata:
76-
name: hybrid-class
99+
name: kong
77100
spec:
78101
controllerName: konghq.com/gateway-operator
79102
parametersRef:
80103
group: gateway-operator.konghq.com
81104
kind: GatewayConfiguration
82-
name: hybrid-configuration
105+
name: kong-configuration
83106
namespace: kong
84-
{% endkonnect_crd %}
85-
<!-- vale on -->
107+
```
86108
87109
## Create a `Gateway` Resource
88110

89111
Now create a `Gateway` resource that references the `GatewayClass` you just created.
90112

91-
<!-- vale off -->
92-
{% konnect_crd %}
113+
```yaml
93114
kind: Gateway
94115
apiVersion: gateway.networking.k8s.io/v1
95116
metadata:
96-
name: hybrid-gateway
117+
name: kong
97118
namespace: kong
98119
spec:
99-
gatewayClassName: hybrid-class
120+
gatewayClassName: kong
100121
listeners:
101122
- name: http
102123
protocol: HTTP
103124
port: 80
104-
{% endkonnect_crd %}
105-
<!-- vale on -->
125+
```
106126

107127
## Validation
108128

109129
{% validation kubernetes-resource %}
110130
kind: Gateway
111-
name: hybrid-gateway
131+
name: kong
132+
namespace: kong
112133
{% endvalidation %}
113134

114-
The respective `DataPlane` and `KonnectGatewayControlPlane` are created automatically by the Gateway Operator.
135+
{: data-deployment-topology="konnect" }
136+
The respective `DataPlane`, `KonnectExtension`, and `KonnectGatewayControlPlane` are created automatically by the Gateway Operator.
137+
{: data-deployment-topology="konnect" }
138+
139+
{: data-deployment-topology="on-prem" }
140+
The respective `DataPlane` and `ControlPlane` are created automatically by the Gateway Operator.
141+
{: data-deployment-topology="on-prem" }

app/_how-tos/operator-get-started-gateway-api-install.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ works_on:
2323
- konnect
2424
- on-prem
2525

26-
min_version:
27-
ko: '2.1'
28-
2926
entities: []
3027

3128
tldr:

app/_includes/on_prem_crd.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div data-deployment-topology="on-prem" markdown="1" data-test-step="block">
2+
```bash{% if should_create_namespace %}
3+
kubectl create namespace kong --dry-run=client -o yaml | kubectl apply -f -{% endif %}
4+
echo '
5+
{{ config | escape_env_variables }}
6+
' | kubectl apply -f -
7+
```
8+
</div>

app/_plugins/blocks/on_prem_crd.rb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# frozen_string_literal: true
2+
3+
require 'yaml'
4+
5+
module Jekyll
6+
class OnPremCrd < Liquid::Block # rubocop:disable Style/Documentation
7+
def initialize(tag_name, markup, tokens)
8+
super
9+
@name = markup.strip
10+
end
11+
12+
def render(context) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
13+
@context = context
14+
@site = context.registers[:site]
15+
@page = context.environments.first['page']
16+
17+
contents = super
18+
19+
unless @page.fetch('works_on', []).include?('on-prem')
20+
raise ArgumentError,
21+
'Page does not contain works_on: on-prem, but uses {% on_prem_crd %}'
22+
end
23+
24+
config = YAML.load(contents)
25+
config = add_defaults(config)
26+
27+
should_create_namespace = config.delete('create_namespace')
28+
29+
# Process YAML for the code block
30+
config = config.to_yaml.delete_prefix("---\n").chomp.gsub(/version: '(.*)'/, 'version: "\1"')
31+
32+
context.stack do
33+
context['config'] = config
34+
context['should_create_namespace'] = should_create_namespace
35+
Liquid::Template.parse(File.read('app/_includes/on_prem_crd.html')).render(context)
36+
end
37+
rescue Psych::SyntaxError => e
38+
message = <<~STRING
39+
On `#{@page['path']}`, the following {% on_prem_crd %} block contains a malformed yaml:
40+
#{contents.strip.split("\n").each_with_index.map { |l, i| "#{i}: #{l}" }.join("\n")}
41+
#{e.message}
42+
STRING
43+
raise ArgumentError, message
44+
end
45+
46+
def add_defaults(config)
47+
48+
defaults = {
49+
'kind' => '@TODO', # Needed to make sure kind is the first item in the YAML output
50+
'apiVersion' => 'gateway-operator.konghq.com/v2beta1',
51+
'metadata' => {
52+
'name' => '@TODO',
53+
'namespace' => 'kong'
54+
},
55+
'spec' => {}
56+
}
57+
58+
defaults.deep_merge(config)
59+
end
60+
end
61+
end
62+
63+
Liquid::Template.register_tag('on_prem_crd', Jekyll::OnPremCrd)

0 commit comments

Comments
 (0)