mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
add DaemonSet targetKind in crd and change label selector
and ignore daemonSetScaleDownNodeSelector in target spec change detection
This commit is contained in:
@@ -87,6 +87,7 @@ spec:
|
||||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- DaemonSet
|
||||
- Deployment
|
||||
- Service
|
||||
name:
|
||||
|
||||
@@ -87,6 +87,7 @@ spec:
|
||||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- DaemonSet
|
||||
- Deployment
|
||||
- Service
|
||||
name:
|
||||
|
||||
@@ -87,6 +87,7 @@ spec:
|
||||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- DaemonSet
|
||||
- Deployment
|
||||
- Service
|
||||
name:
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
daemonSetScaleDownNodeSelector = map[string]string{"flagger.weave.works/non-exist": "true"}
|
||||
daemonSetScaleDownNodeSelector = map[string]string{"flagger.app/scale-to-zero": "true"}
|
||||
)
|
||||
|
||||
// DaemonSetController is managing the operations for Kubernetes DaemonSet kind
|
||||
@@ -97,8 +97,7 @@ func (c *DaemonSetController) Initialize(cd *flaggerv1.Canary, skipLivenessCheck
|
||||
}
|
||||
}
|
||||
|
||||
// delete canary daemonset
|
||||
c.logger.With("canary", fmt.Sprintf("%s.%s", cd.Name, cd.Namespace)).Infof("Deleting %s.%s", cd.Spec.TargetRef.Name, cd.Namespace)
|
||||
c.logger.With("canary", fmt.Sprintf("%s.%s", cd.Name, cd.Namespace)).Infof("Scaling down %s.%s", cd.Spec.TargetRef.Name, cd.Namespace)
|
||||
if err := c.Scale(cd, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -179,6 +178,11 @@ func (c *DaemonSetController) HasTargetChanged(cd *flaggerv1.Canary) (bool, erro
|
||||
return false, fmt.Errorf("daemonset %s.%s query error %v", targetName, cd.Namespace, err)
|
||||
}
|
||||
|
||||
// ignore `daemonSetScaleDownNodeSelector` node selector
|
||||
for key := range daemonSetScaleDownNodeSelector {
|
||||
delete(canary.Spec.Template.Spec.NodeSelector, key)
|
||||
}
|
||||
|
||||
return hasSpecChanged(cd, canary.Spec.Template)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
// SyncStatus encodes the canary pod spec and updates the canary status
|
||||
func (c *DaemonSetController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error {
|
||||
dep, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{})
|
||||
dae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
return fmt.Errorf("daemonset %s.%s not found", cd.Spec.TargetRef.Name, cd.Namespace)
|
||||
@@ -19,12 +19,17 @@ func (c *DaemonSetController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.
|
||||
return ex.Wrap(err, "SyncStatus daemonset query error")
|
||||
}
|
||||
|
||||
// ignore `daemonSetScaleDownNodeSelector` node selector
|
||||
for key := range daemonSetScaleDownNodeSelector {
|
||||
delete(dae.Spec.Template.Spec.NodeSelector, key)
|
||||
}
|
||||
|
||||
configs, err := c.configTracker.GetConfigRefs(cd)
|
||||
if err != nil {
|
||||
return ex.Wrap(err, "SyncStatus configs query error")
|
||||
}
|
||||
|
||||
return syncCanaryStatus(c.flaggerClient, cd, status, dep.Spec.Template, func(cdCopy *flaggerv1.Canary) {
|
||||
return syncCanaryStatus(c.flaggerClient, cd, status, dae.Spec.Template, func(cdCopy *flaggerv1.Canary) {
|
||||
cdCopy.Status.TrackedConfigs = configs
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: podinfo
|
||||
namespace: test
|
||||
labels:
|
||||
app: podinfo
|
||||
spec:
|
||||
minReadySeconds: 5
|
||||
revisionHistoryLimit: 5
|
||||
selector:
|
||||
matchLabels:
|
||||
app: podinfo
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "9797"
|
||||
labels:
|
||||
app: podinfo
|
||||
spec:
|
||||
containers:
|
||||
- name: podinfod
|
||||
image: stefanprodan/podinfo:3.1.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 9898
|
||||
protocol: TCP
|
||||
- name: http-metrics
|
||||
containerPort: 9797
|
||||
protocol: TCP
|
||||
- name: grpc
|
||||
containerPort: 9999
|
||||
protocol: TCP
|
||||
command:
|
||||
- ./podinfo
|
||||
- --port=9898
|
||||
- --port-metrics=9797
|
||||
- --grpc-port=9999
|
||||
- --grpc-service-name=podinfo
|
||||
- --level=info
|
||||
- --random-delay=false
|
||||
- --random-error=false
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 9898
|
||||
path: /healthz
|
||||
initialDelaySeconds: 5
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 9898
|
||||
path: /readyz
|
||||
initialDelaySeconds: 5
|
||||
timeoutSeconds: 5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 128Mi
|
||||
requests:
|
||||
cpu: 1m
|
||||
memory: 16Mi
|
||||
@@ -15,7 +15,7 @@ kubectl apply -k ${REPO_ROOT}/kustomize/tester
|
||||
kubectl -n test rollout status deployment/flagger-loadtester
|
||||
|
||||
echo '>>> Initialising canary'
|
||||
kubectl apply -f ${REPO_ROOT}/test/e2e-workload.yaml
|
||||
kubectl apply -f ${REPO_ROOT}/test/e2e-daemonset.yaml
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: flagger.app/v1alpha3
|
||||
|
||||
Reference in New Issue
Block a user