-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Flux applies changes to the cluster very slowly #1422
Comments
Do individual applies take 4-6 seconds if you try that locally?
As I understand it, flux is deploying files or directories one at a time and this might be inefficient. |
As a bit of background: when flux runs a sync, it does it in two stages:
The rationale for this is that if there are no problematic resources (i.e., step 1 sails through) it is much faster. (Though it could be better -- e.g., #1410 passes information about the previous sync back to the process, so it can make an informed guess about which approach will work best.) From the logs, it looks like it's doing both the "big bang" I'd be interested to know if doing
|
@justinbarrick Run locally, individual applies also finish very quickly, and don't exhibit the same problem. @squaremo Interesting, thanks for the background info! We had one YAML manifest containing a formatting error, which must have been why flux was doing the sync in two stages. I tested
Each of the API calls takes either 8-15ms or, randomly, 2-5 seconds. 💥 The reason I was unable to reproduce this elsewhere was because flux is making around 100 requests to the API server per |
Nice sleuthing! I wonder why that bit of filesystem is read-only. Do you mount your own kubeconfig file from a configmap? |
We're installing flux from the helm chart, which does provide a default kubeconfig ConfigMap, but we haven't changed the defaults in any way. apiVersion: v1
data:
config: |
apiVersion: v1
clusters: []
contexts:
- context:
cluster: ""
namespace: default
user: ""
name: default
current-context: default
kind: Config
preferences: {}
users: []
kind: ConfigMap
metadata:
annotations:
flux.weave.works/antecedent: cluster-admin:fluxhelmrelease/flux
creationTimestamp: 2018-09-28T18:42:14Z
name: flux-kube-config
namespace: cluster-admin
resourceVersion: "274875"
selfLink: /api/v1/namespaces/cluster-admin/configmaps/flux-kube-config
uid: 37ce4bcc-c34e-11e8-a95e-062485839578 |
Ahhh that'll be it then -- configmaps and secrets are mounted read-only, and since we mount it at https://github.com/weaveworks/flux/blob/master/cluster/kubernetes/sync.go#L149 suggests that the an environment entry for the container would carry through to |
@stefanprodan Something to try in the Helm chart I reckon ^ |
To follow up on this: I opened a ticket with our cloud provider (Azure) and found out that this was also the cause of the degraded API server performance. I updated our flux chart with the changes from #1435 and the problem vanished. Thanks for the quick fix! |
The linked issue fluxcd#1422 is not rendered in Read the docs as a link. https://docs.fluxcd.io/en/stable/troubleshooting.html#flux-is-taking-a-long-time-to-apply-manifests-when-it-syncs This change fixes the rendering to follow the `[fluxcd/flux#number]` format used else where in the docs.
Recently we've begun to see a significant increase in the amount of time flux takes to sync the git repository to the cluster:
Based on the flux logs, it looks like individual
kubectl apply
calls are taking 6-11 seconds to return:In contrast, syncing the entire git repo from my local machine takes under 5 seconds.
I launched a copy of
k8s.gcr.io/hyperkube:v1.9.0
in the cluster, rankubectl apply -Rf
on a clone of our git repository, and it completed quickly there as well. I also tried moving the flux pod to a different node on the cluster to rule out a transient network issue, but there was no effect. It seems only flux is affected.Let me know if there's any other information I can provide to help troubleshoot this, because I'm stumped.
k8s version: 1.11.2
flux: 1.7.1
(initial discussion)
The text was updated successfully, but these errors were encountered: