Repository navigation
kflare v0.3.0
The fourth alpha release of kflare: the API is still v1alpha1, and it needs Kubernetes 1.34 or newer. Five more kinds
are now generated by kflare's code generator, on Cloudflare's generated Go SDK, as the Rules products' kinds already
were: the three security rule kinds, WAFCustomRule, RateLimitRule and ManagedRuleset, so that every rule kind is
generated, and R2Bucket and WorkerRoute, the first of the kinds written before the generator to move onto it.
The rule kinds' fields take the names of Cloudflare's API, so manifests written for v0.2 change: read
Upgrading from v0.2.1 before upgrading. It is a minor release because of that change.
R2Bucket and WorkerRoute apply manifests unchanged, but behave differently in the ways their sections list. The
other kinds written before the generator (Zone, DNSRecord, Tunnel, TunnelConfiguration, WorkerScript and
IPList) are unchanged: they move onto it in later releases, whose notes list their changes the same way. The chart
also gains an Artifact Hub page with its license, CRDs and security report.
helm upgrade kflare oci://ghcr.io/jonathangraniero/charts/kflare --version 0.3.0 -n kflare-system \
--values kflare-values.yamlThe image is ghcr.io/jonathangraniero/kflare:0.3.0, for linux/amd64 and linux/arm64. The deploy guide's
Verifying a release checks both signatures before you install. To install kflare
for the first time, follow the README's quickstart.
Upgrading from v0.2.1
The chart's values and the controller's permissions are v0.2.1's, and so are the other CRDs but R2Bucket's and
WorkerRoute's, whose manifests need no change. Only the WAFCustomRule, RateLimitRule and ManagedRuleset
resources do; if this lists none, they need nothing:
kubectl get wafcustomrules,ratelimitrules,managedrulesets -ACheck your R2Buckets before upgrading as well. spec.storageClass defaults to Standard, and kflare now sets a
bucket's storage class: a bucket whose class was set to InfrequentAccess outside kflare goes back to Standard
unless its R2Bucket says InfrequentAccess. Pause such an R2Bucket before upgrading
(kubectl annotate r2bucket <name> kflare.dev/paused=true), apply its manifest with storageClass: InfrequentAccess
after the chart, then remove the annotation (kubectl annotate r2bucket <name> kflare.dev/paused-). An alert on a
WorkerRoute's PatternOutsideZone reason needs changing too (WorkerRoute).
For the three rule kinds:
- Rewrite their manifests in the new shape, from the sections below, each with a manifest before and after. Keep
them back for now: the v0.2.1 CRDs refuse the new fields (unknown field "spec.ratelimit") - Pause each
WAFCustomRulewith ablockResponse, withkubectl annotate wafcustomrule <name> kflare.dev/paused=true. Upgraded, such a rule loses its response, and kflare would write it again without one - Upgrade the chart, which upgrades the CRDs. If you manage the CRDs yourself (
crds.enabled=false), apply
config/crd/basesfrom v0.3.0 first - Apply the rewritten manifests right away, then remove the annotations from step 2, with
kubectl annotate wafcustomrule <name> kflare.dev/paused-. With Argo CD or Flux, sync them after the chart
Between steps 3 and 4, a stored resource has lost its old fields: the API server drops the fields the new CRD does not
know when it reads the resource. The RateLimitRule and WAFCustomRule sections below say what kflare does with
their Cloudflare rules until you apply the new shape. Until then a change to the resource's spec is refused
(spec.id: Required value), but one to its metadata or status is not, so it can still be paused, report its status
and be deleted.
ManagedRuleset
rulesetIDis nowid, the API's name for the ruleset an execute rule runs. A ManagedRuleset stored with
rulesetIDhas noidafter the upgrade, and cannot be updated until it gets one: apply your ManagedRuleset
manifests withidright after upgradingidcan change in place, which updates the deployment's rule to run the other ruleset; it was immutable- The category and rule overrides are sent in the spec's order rather than sorted. Cloudflare keeps that order, so
reordering them in the spec writes the rule again - An empty
overrides.categoriesoroverrides.rulesis refused: leave it out - For Go clients:
ManagedRulesetCategoryOverrideandManagedRulesetRuleOverrideare now
ManagedRulesetOverridesCategoryandManagedRulesetOverridesRule, and an override'sactionis astring
Before:
spec:
zoneRef:
name: example-zone
rulesetID: 77454fe2d30c4220b5701f6fdfb893ba
expression: "true"
overrides:
categories:
- category: wordpress
action: logAfter:
spec:
zoneRef:
name: example-zone
id: 77454fe2d30c4220b5701f6fdfb893ba
expression: "true"
overrides:
categories:
- category: wordpress
action: logRateLimitRule
- The rate limit moves under
ratelimit, the API's name for it:characteristics,period,requestsPerPeriod,
mitigationTimeout,countingExpressionandrequestsToOrigin.blockResponseis nowresponse. A
RateLimitRule stored with the old fields has no rate limit after the upgrade, and cannot be updated until it gets
one: apply your RateLimitRule manifests in the new shape right after upgrading. Until then its Cloudflare rule is
left as it was - Nothing defaults any more: set
action(wasblock),ratelimit.characteristics(was[ip.src]),
ratelimit.period(was 10),ratelimit.mitigationTimeout(was the period; 0 throttles, on Enterprise plans) and
response.statusCode(was 429) ratelimit.characteristicsmust listcf.colo.id, which kflare no longer adds for you, and at least one other
field. They are sent sorted- For Go clients:
RateLimitRuleBlockResponseis nowRateLimitRuleResponse, the rate limit is a
RateLimitRuleRatelimit, its characteristics are[]string, and its integers areint64, the optional ones
pointers
Before:
spec:
zoneRef:
name: example-zone
expression: 'starts_with(http.request.uri.path, "/api/")'
requestsPerPeriod: 100
blockResponse:
contentType: application/json
content: '{"error":"rate limited"}'After:
spec:
zoneRef:
name: example-zone
expression: 'starts_with(http.request.uri.path, "/api/")'
action: block
ratelimit:
characteristics: [cf.colo.id, ip.src]
period: 10
requestsPerPeriod: 100
mitigationTimeout: 10
response:
statusCode: 429
contentType: application/json
content: '{"error":"rate limited"}'WAFCustomRule
- A skip rule's parameters move to the spec's root, as the API names them:
skip.remainingRules: trueis now
ruleset: current, andskip.phasesandskip.productsarephasesandproducts.skip.logis now
logging.enabled, andblockResponseis nowresponse - A WAFCustomRule stored with the old fields loses them after the upgrade:
- A skip rule then has no parameters, which Cloudflare refuses (20115): kflare reports
TerminalErrorand leaves
the Cloudflare rule as it was until you apply the manifest in the new shape - A block rule with a
blockResponsebecomes a plain block rule, and kflare writes its Cloudflare rule again
without the response. Pause such rules (kflare.dev/paused: "true") before upgrading, apply them in the new
shape, then remove the annotation
- A skip rule then has no parameters, which Cloudflare refuses (20115): kflare reports
- Nothing defaults any more: set
response.statusCode(was 403). A skip rule withoutloggingstill logs its
matches, Cloudflare's default, which kflare no longer sends itself - New:
phase: currentskips the rest of the phase, the custom rulesets that run later in it included. It combines
withproducts, but not withphasesorruleset - For Go clients:
WAFCustomRuleSkip,WAFCustomRuleSkipPhase,WAFCustomRuleSkipProductand
WAFCustomRuleBlockResponseare gone. The phases and products are[]string, the response is a
WAFCustomRuleResponsewhosestatusCodeis anint64, and logging is aWAFCustomRuleLogging
Before:
spec:
zoneRef:
name: example-zone
expression: 'http.request.uri.path eq "/healthz"'
action: skip
skip:
remainingRules: true
phases: [http_ratelimit]
log: false
---
spec:
zoneRef:
name: example-zone
expression: 'http.request.uri.path wildcard "/admin*"'
action: block
blockResponse:
contentType: text/plain
content: BlockedAfter:
spec:
zoneRef:
name: example-zone
expression: 'http.request.uri.path eq "/healthz"'
action: skip
ruleset: current
phases: [http_ratelimit]
logging:
enabled: false
---
spec:
zoneRef:
name: example-zone
expression: 'http.request.uri.path wildcard "/admin*"'
action: block
response:
statusCode: 403
contentType: text/plain
content: BlockedR2Bucket
jurisdiction:default,euoruskeep the bucket's objects in that jurisdiction (fedrampand
fedramp-highneed a FedRAMP account). Each jurisdiction has buckets of its own, so two R2Buckets can name buckets
of the same name in different jurisdictions. It defaults todefault, the only jurisdiction kflare reached before,
and cannot changestorageClass:StandardorInfrequentAccess, the class of objects uploaded to the bucket without one of
their own, changed in place. It defaults toStandard, so a bucket whose class was set toInfrequentAccess
outside kflare is set back toStandardunless its R2Bucket saysInfrequentAccess- A WorkerScript does not bind an R2Bucket outside the default jurisdiction yet: it reports
R2BucketJurisdictionUnsupported(it still uploads through the legacy SDK, whose binding has no jurisdiction) - Status:
cloudflareMetadata.bucketNamerecords the bucket kflare created or adopted, andcreationDateis
Cloudflare's timestamp as a string.kubectl get r2bucketsshows the jurisdiction, the bucket and its location - The claim label stays
kflare.dev/r2-bucket-name, so an upgraded R2Bucket keeps its bucket - For Go clients:
R2BucketNameLabelis nowR2BucketIDLabel, andR2BucketCloudflareMetadata.CreationDatea
string
Before and after: a v0.2.1 manifest, such as
spec:
accountRef:
name: example-account
name: example-assets
locationHint: weurreads back with the defaults:
spec:
accountRef:
name: example-account
name: example-assets
locationHint: weur
jurisdiction: default
storageClass: StandardWorkerRoute
- The spec and status are unchanged:
zoneRef,patternand an optionalworkerScriptRef, androuteID,zoneID
andscriptinstatus.cloudflareMetadata. A v0.2.1 manifest applies and reads back as it is - A pattern outside the zone is reported as Cloudflare's refusal:
TerminalError, with Cloudflare's message
("Route pattern must include zone name: example.com", 10022), where kflare reportedPatternOutsideZonebefore
calling Cloudflare. An alert onPatternOutsideZoneneeds changing - A claim on a route counts only from a WorkerRoute whose Zone is for the same Cloudflare zone, through any Zone
- The sample in
config/samplesis generated: one route, kept on deletion. The exclusion route it showed is a
WorkerRoute withoutworkerScriptRef, as before
Generated kinds
- A claim on a
KVNamespace's,D1Database's orR2Bucket's Cloudflare object counts only from a resource that uses
the same Cloudflare account, through anyCloudflareAccount, and on aWorkerRoute's from one in the same
Cloudflare zone, through anyZone. One whoseCloudflareAccountorZoneis gone no longer keeps another
resource from adopting the object
The Helm chart
- The chart's Artifact Hub page lists its license, its CRDs with an example of each, each release's changes, and
the controller image, which Artifact Hub now scans for its security report. It found no image before: it renders a
chart for Kubernetes 1.29 to find them, which the chart refuses
(#90)
The controller
- A Ready condition no longer ends in a blank message when Cloudflare's error holds only spaces: it names the HTTP
status, as it does for an error without a message. Found by the new fuzz tests
(#108)
Known limitations
v0.2.0's, unchanged: ARCHITECTURE.md explains each.