-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add a kusion-control label in svc labels #510
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,17 @@ const ( | |
suffixPublic = "public" | ||
suffixPrivate = "private" | ||
|
||
// aliyun SLB annotations, ref: https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/add-annotations-to-the-yaml-file-of-a-service-to-configure-clb-instances?spm=a2c4g.11186623.0.0.59e26219ESUbqe | ||
// aliyun SLB annotations, ref: https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/add-annotations-to-the-yaml-file-of-a-service-to-configure-clb-instances | ||
aliyunLBSpec = "service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec" | ||
aliyunSLBS1Small = "slb.s1.small" | ||
kusionControl = "kusionstack.io/control" | ||
) | ||
|
||
var ( | ||
ErrEmptyAppName = errors.New("app name must not be empty") | ||
ErrEmptyProjectName = errors.New("project name must not be empty") | ||
ErrEmptyStackName = errors.New("stack name must not be empty") | ||
ErrEmptySelectors = errors.New("selectors must not be empty") | ||
ErrEmptyPorts = errors.New("ports must not be empty") | ||
ErrInvalidPort = errors.New("port must be between 1 and 65535") | ||
ErrInvalidTargetPort = errors.New("targetPort must be between 1 and 65535 if exist") | ||
ErrInvalidProtocol = errors.New("protocol must be TCP or UDP") | ||
|
@@ -163,16 +163,13 @@ func (g *portsGenerator) generateK8sSvc(public bool, ports []network.Port) *v1.S | |
|
||
// only support Aliyun SLB for now, and set SLB spec by default. | ||
svc.Annotations[aliyunLBSpec] = aliyunSLBS1Small | ||
svc.Labels[kusionControl] = "true" | ||
} | ||
|
||
return svc | ||
} | ||
|
||
func validatePorts(ports []network.Port) error { | ||
if len(ports) == 0 { | ||
return ErrEmptyPorts | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't want to render k8s service, should check the length of ports before new ports generator. If empty, don't new the generator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the ports are nil, the logic below will return immediately. I don't understand why this generator will fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1, I don't know what is "the logic below" you refer to. Besides, what will get returned? an error, or an empty result? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
portProtocolRecord := make(map[string]struct{}) | ||
for _, port := range ports { | ||
if err := validatePort(&port); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you need to add this label? K8s Service will Inherit the label that Collaset/Deployment have, does they don't have the label of kusionControl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This label is used to cooperate with the KAFE svc controller to implement gracefully rollout. The KAFE svc controller will only process svcs with this label and it is given in the svc sample before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this. But I want to know does this label is not attached to the KAFE workload, Collaset? Does it only need to attach to the service?
This label works only for KAFE system, should not get added under other situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only works with the KAFE workload. We will move this label and all Aliyun-related labels to platform.k in the next version