VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
430 stars 144 forks source link

VMOperator drops Ingress created without using it #758

Closed thunderbird86 closed 1 month ago

thunderbird86 commented 1 year ago

Describe the bug

VMOperator drops Ingress created without using it if it has the same name as an operator-managed resource. Probably it can be related not only to Ingress but to other resources too

To Reproduce

Deploy resource using VMOperater e.g. vmauth

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAuth
metadata:
  name: vmauth-sample
spec:
  replicaCount: 1
  resources:
    limits:
      cpu: 500m
      memory: 850Mi
    requests:
      cpu: 250m
      memory: 350Mi
  selectAllByDefault: true

Deploy Ingress using kubectl

---
apiVersion: v1
kind: Service
metadata:
  name: vmauth-sample
spec:
  type: ClusterIP
  ports:
    - name: service
      port: 8427
      protocol: TCP
      targetPort: 8427
  selector:
    app.kubernetes.io/name: vmauth

Expectation

Both resources work fine

Actual Result

VMOperator drops ingress

f41gh7 commented 1 year ago

It would be great to store dynamic linked resources ( ingress, hpa, psp, pdb, rbac policy) at resource annotation. And perform 3-way merge ( new config state, cluster config state, annotations config state) like kubectl does.

user81230 commented 11 months ago

Finally, I found the cause of VMOperator dropping my ingresses. This affected us too, and renaming ingresses solved the problem. Maybe it is a good practice to give all the resources unique names, regardless of their kind.

I suggest parsing Kubernetes resources together with their name (like "ingress/vmauth-sample" instead of just "vmauth-sample") in the operator's internals.

f41gh7 commented 1 month ago

Bug was fixed at v0.48.3 release.

Now operator will perform Ingress delete operation only if it was defined at VMAuth spec.