-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Validate manifests with API server dry run #2282
Comments
I am familiar with the |
I think it behaves the same as apply:
See: |
I think the server dry run should be opt-in via a Flux command flag. Not every validation controller has support for it e.g. open-policy-agent/gatekeeper#128 |
This is a big ➕ compared to what we have now, and given that there is no difference, it would not make sense to still try to apply the resources that would fail. Question remains if we want to apply a partial set (by filtering out what makes it fail), or skip the whole apply. I am inclined to choose for the latter as we strive to maintain a valid state. |
I vote for skipping the apply all together if the validation fails. |
Looks like we need a two stage validation/apply procedure since the custom resources will fail if the CRDs are not applied. CRD + CR: apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: tests.k8s.io
annotations:
helm.sh/resource-policy: keep
spec:
group: k8s.io
version: v1
versions:
- name: v1
served: true
storage: true
names:
plural: tests
singular: test
kind: Test
categories:
- all
scope: Namespaced
---
apiVersion: k8s.io/v1
kind: Test
metadata:
name: test
namespace: test
spec:
some: value Dry run result:
|
We've encountered the problem of deployments failing because of validation errors a couple of times - and not having a good way to communicate back to the right person, has been a bit problematic. Logging this in an easy detectable way would be a great first step. Would it be possible to consider an option with a webhook also? We have a service; |
In order to validate the content of a commit before pushing it to our gitops master branch (e.g. in a pull request) I would find it very helpful to be able to call fluxd in a dryrun only way. Could that be possible as well ? |
@tobias-jenkner, I'm in the same boat. I'd like to pass the dry run output (from a CLI command?) to |
What we thought that could be a good idea, is to have flux --dry-run or even plugin some more validations for other than source branch, in this case, it could be integrated to git-flow process, like
So basically we are also in the same boat. |
The API server dry-run was implemented in the GitOps toolkit and can be enabled with |
I dont see any way to enable this under the documentation linked, has this functionality changed? |
@jamiedick Yes, it has changed since Flux 0.18 – the validation is a required part of Server-Side Apply, so it is enabled by default now and cannot be disabled anymore. So the The field was left in place to smooth upgrading, if you find it in the API docs it should say something to this effect:
|
Starting with Kubernetes 1.13 the API dry run is enabled by default. Flux could run
kubectl apply --server-dry-run
before trying to apply the manifest. We could log the validation errors in such a way that's easy to detect with a log parser like Fluentd/CloudWatch/Stackdriver/etc (#1340). We could also expose a Prometheus metric with the validation errors count (#2199).To avoid custom resources no match errors, the validation and apply should be done in stages:
server-dry-run
on the CRDsserver-dry-run
on all manifestThe text was updated successfully, but these errors were encountered: