Skip to content

Commit 40f8619

Browse files
authored
Merge pull request #6 from replicatedhq/pagerules
Add pagerules to the CRD
2 parents 53d9c68 + 2e71f32 commit 40f8619

19 files changed

+1182
-5
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.2.8
8+
creationTimestamp: null
9+
name: pagerules.crds.kubeflare.io
10+
spec:
11+
group: crds.kubeflare.io
12+
names:
13+
kind: PageRule
14+
listKind: PageRuleList
15+
plural: pagerules
16+
singular: pagerule
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
description: PageRule is the Schema for the pagerules API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation
26+
of an object. Servers should convert recognized schemas to the latest
27+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28+
type: string
29+
kind:
30+
description: 'Kind is a string value representing the REST resource this
31+
object represents. Servers may infer this from the endpoint the client
32+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33+
type: string
34+
metadata:
35+
type: object
36+
spec:
37+
description: PageRuleSpec defines the desired state of PageRule
38+
properties:
39+
pageRule:
40+
properties:
41+
alwaysUseHttps:
42+
type: object
43+
autoMinify:
44+
properties:
45+
css:
46+
type: boolean
47+
html:
48+
type: boolean
49+
js:
50+
type: boolean
51+
required:
52+
- css
53+
- html
54+
- js
55+
type: object
56+
enabled:
57+
type: boolean
58+
forwardingUrl:
59+
properties:
60+
redirectUrl:
61+
type: string
62+
statusCode:
63+
type: integer
64+
required:
65+
- redirectUrl
66+
- statusCode
67+
type: object
68+
priority:
69+
type: integer
70+
requestUrl:
71+
type: string
72+
required:
73+
- requestUrl
74+
type: object
75+
zone:
76+
type: string
77+
required:
78+
- zone
79+
type: object
80+
status:
81+
description: PageRuleStatus defines the observed state of PageRule
82+
properties:
83+
id:
84+
type: string
85+
type: object
86+
type: object
87+
served: true
88+
storage: true
89+
subresources:
90+
status: {}
91+
status:
92+
acceptedNames:
93+
kind: ""
94+
plural: ""
95+
conditions: []
96+
storedVersions: []

config/crds/v1/crds.kubeflare.io_zones.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
type: boolean
4949
alwaysUseHttps:
5050
type: boolean
51-
automaticHTTSRewrites:
51+
automaticHTTPSRewrites:
5252
type: boolean
5353
brotli:
5454
type: boolean
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.2.8
8+
creationTimestamp: null
9+
name: pagerules.crds.kubeflare.io
10+
spec:
11+
group: crds.kubeflare.io
12+
names:
13+
kind: PageRule
14+
listKind: PageRuleList
15+
plural: pagerules
16+
singular: pagerule
17+
scope: Namespaced
18+
subresources:
19+
status: {}
20+
validation:
21+
openAPIV3Schema:
22+
description: PageRule is the Schema for the pagerules API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation
26+
of an object. Servers should convert recognized schemas to the latest
27+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28+
type: string
29+
kind:
30+
description: 'Kind is a string value representing the REST resource this
31+
object represents. Servers may infer this from the endpoint the client
32+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33+
type: string
34+
metadata:
35+
type: object
36+
spec:
37+
description: PageRuleSpec defines the desired state of PageRule
38+
properties:
39+
pageRule:
40+
properties:
41+
alwaysUseHttps:
42+
type: object
43+
autoMinify:
44+
properties:
45+
css:
46+
type: boolean
47+
html:
48+
type: boolean
49+
js:
50+
type: boolean
51+
required:
52+
- css
53+
- html
54+
- js
55+
type: object
56+
enabled:
57+
type: boolean
58+
forwardingUrl:
59+
properties:
60+
redirectUrl:
61+
type: string
62+
statusCode:
63+
type: integer
64+
required:
65+
- redirectUrl
66+
- statusCode
67+
type: object
68+
priority:
69+
type: integer
70+
requestUrl:
71+
type: string
72+
required:
73+
- requestUrl
74+
type: object
75+
zone:
76+
type: string
77+
required:
78+
- zone
79+
type: object
80+
status:
81+
description: PageRuleStatus defines the observed state of PageRule
82+
properties:
83+
id:
84+
type: string
85+
type: object
86+
type: object
87+
version: v1alpha1
88+
versions:
89+
- name: v1alpha1
90+
served: true
91+
storage: true
92+
status:
93+
acceptedNames:
94+
kind: ""
95+
plural: ""
96+
conditions: []
97+
storedVersions: []

config/crds/v1beta1/crds.kubeflare.io_zones.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
type: boolean
4949
alwaysUseHttps:
5050
type: boolean
51-
automaticHTTSRewrites:
51+
automaticHTTPSRewrites:
5252
type: boolean
5353
brotli:
5454
type: boolean

docs/docs/api/dnsrecord.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# DNS Record
22

3+
A `kind: DNSRecord` resource will manage one or more DNS records in a managed [zone](../zone).
4+
Each resource can contain a single DNS record when specified under `spec.record` vs `spec.records`.
5+
6+
## Attributes
7+
8+
### Zone
9+
10+
Each `kind: DNSRecord` must contain a `spec.zone` string attribute.
11+
The value of this attribute must match a [zone](../zone) managed by Kubeflare.
12+
The API token to manage the DNS record(s) will be read from the associated Zone kind resource.
13+
14+
### Record(s)
15+
16+
For more information on this type, see the [Cloudflare documentation](https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record).
17+
18+
The following attributes are supported in the `record` or `records` object:
19+
20+
| Name | Type | Description |
21+
|------|------|-------------|
22+
| type | string | The DNS record type
23+
| name | string | The DNS record name
24+
| content | string | The DNS record content
25+
| ttl | int | Time to live for the record. (set to 1 for auto)
26+
| proxied (optional)| boolean | When true, proxy the record through Cloudflare
27+
28+
## Examples
29+
30+
### Single A Record
31+
32+
The following example will ensure that a single A record for `www` exists, proxied, and pointing to 1.1.1.1:
33+
334
```yaml
435
apiVersion: crds.kubeflare.io/v1alpha1
536
kind: DNSRecord
@@ -15,6 +46,10 @@ spec:
1546
ttl: 3600
1647
```
1748
49+
### Multiple MX Records
50+
51+
The following example will configure GSuite MX records for a domain:
52+
1853
```yaml
1954
apiVersion: crds.kubeflare.io/v1alpha1
2055
kind: DNSRecord

docs/docs/api/pagerules.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# PageRule
2+
3+
A `kind: PageRule` resource will manage one or more PageRules in a manage [zone](../zone).
4+
Each resource contains a single PageRule record.
5+
6+
## Attributes
7+
8+
### Zone
9+
10+
Each `kind: PageRule` must contain a `spec.zone` string attribute.
11+
The value of this attribute must match a [zone](../zone) managed by Kubeflare.
12+
The API token to manage the DNS record(s) will be read from the associated Zone kind resource.
13+
14+
### PageRule
15+
16+
For more information on this type, see the [Cloudflare documentation](https://api.cloudflare.com/#page-rules-for-a-zone-create-page-rule).
17+
18+
The following attributes are supported in the `pagerule` or `pagerules` object.
19+
Priority and status are optional, and at least one of the other fields (rules) should be present on the object.
20+
Check the Cloudflare documentation to ensure the combination of rules (settings) are compatbile.
21+
22+
| Name | Type | Description |
23+
|------|------|-------------|
24+
| requestUrl | string | The incoming (original) request url |
25+
| priority | int | |
26+
| enabled | boolean | |
27+
| alwaysOnline | [AlwaysOnline](#alwaysonline) | When present, the always online page rule
28+
| alwaysUseHttps | [AlwaysUseHTTPS](#alwaysusehttps) | When present, the always use https page rule
29+
| autoMinify | [AutoMinify](#autominify) | When present, the auto minify page rule
30+
| forwardingUrl | [ForwardingURL](#forwardingurl) | When present, the forwarding url page rule
31+
32+
### AlwaysOnline
33+
34+
The AlwaysOnline object describes the always online page rule.
35+
36+
| Name | Type | Description |
37+
|------|------|-------------|
38+
| enabled | boolean | The value of the always online setting |
39+
40+
### AlwaysUseHTTPS
41+
42+
The AlwaysUseHTTPS object is an empty object that enables the always use https pagerule.
43+
44+
### AutoMinify
45+
46+
The AutoMinify object describes an auto minify page rule settings.
47+
48+
| Name | Type | Description |
49+
|------|------|-------------|
50+
| html | boolean | The value for the html setting |
51+
| css | boolean | The value for the css setting |
52+
| js | boolean | The value for the js setting |
53+
54+
55+
### ForwardingURL
56+
57+
The ForwardingURL object describes a forwarding url page rule.
58+
59+
| Name | Type | Description |
60+
|------|------|-------------|
61+
| statusCode | int | 301 or 302, the status code to send |
62+
| redirectUrl | string | The redirect/forwarded url |
63+
64+
65+
## Examples
66+
67+
### Redirect (forward) www to apex domain
68+
69+
The following PageRule manifest will forward requests made to www.example.com to example.com:
70+
71+
```yaml
72+
apiVersion: crds.kubeflare.io/v1alpha1
73+
kind: PageRule
74+
metadata:
75+
name: www.example.com
76+
spec:
77+
zone: example.com
78+
rule:
79+
requestUrl: "www.example.com/*"
80+
forwardingUrl:
81+
statusCode: 302
82+
redirectUrl: "https://example.com/$1
83+
```
84+
85+
### Always Use HTTPS
86+
87+
The following PageRule manifest will enable always use https on a specific path:
88+
89+
```yaml
90+
apiVersion: crds.kubeflare.io/v1alpha1
91+
kind: PageRule
92+
metadata:
93+
name: www.example.com
94+
spec:
95+
zone: example.com
96+
rule:
97+
requestUrl: "www.example.com/*"
98+
alwaysUseHttps: {}
99+
```

docs/docs/api/zone.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Zone
22

3-
A `kind: Zone` resource is created per domain name that's managed in Cloudflare.
3+
A `kind: Zone` resource should be created per domain name that's managed in Cloudflare.
44
Here you can specify the API Token and any Zone settings.
55

66
A `kind: Zone` resource is required in order to configure any additional api types on a Cloudflare domain.
@@ -59,7 +59,7 @@ spec:
5959
## `settings`
6060

6161
All [Cloudflare Zone Settings](https://api.cloudflare.com/#zone-settings-properties) can be specified in the `settings` key of this resource.
62-
Kubeflare uses a lowerCamelCase standard to specify all fields in the Cloudflare Zone, while Cloudflare uses both snake_case and lowerCamelCase at times.
62+
Kubeflare uses a lowerCamelCase standard to specify all fields in the Cloudflare Zone.
6363

6464
Note that the Cloudflare API and docs use string types with values of "off" and "on" for boolean settings.
6565
Kubeflare uses boolean objects (true, false) and will map those to the string types accepted by Cloudflare.

0 commit comments

Comments
 (0)