Skip to content
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

improve nodepool conversion #2080

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
improve nodepool conversion
  • Loading branch information
rambohe-ch committed Jun 18, 2024
commit ef6ae46e525004e0939a19ff84ca854fdef721a5
13 changes: 13 additions & 0 deletions pkg/apis/apps/v1alpha1/nodepool_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 17,12 @@ limitations under the License.
package v1alpha1

import (
"strings"

"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/conversion"

"github.com/openyurtio/openyurt/pkg/apis/apps"
"github.com/openyurtio/openyurt/pkg/apis/apps/v1beta1"
)

Expand All @@ -32,6 35,9 @@ func (src *NodePool) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Labels = src.Spec.Labels
dst.Spec.Annotations = src.Spec.Annotations
dst.Spec.Taints = src.Spec.Taints
if strings.EqualFold(src.Annotations[apps.NodePoolHostNetworkLabel], "true") {
dst.Spec.HostNetwork = true
}

dst.Status.ReadyNodeNum = src.Status.ReadyNodeNum
dst.Status.UnreadyNodeNum = src.Status.UnreadyNodeNum
Expand All @@ -56,6 62,13 @@ func (dst *NodePool) ConvertFrom(srcRaw conversion.Hub) error {
dst.Status.UnreadyNodeNum = src.Status.UnreadyNodeNum
dst.Status.Nodes = src.Status.Nodes

if src.Spec.HostNetwork {
if dst.Annotations == nil {
dst.Annotations = make(map[string]string)
}
dst.Annotations[apps.NodePoolHostNetworkLabel] = "true"
}

klog.V(4).Infof("convert from v1beta1 to v1alpha1 for nodepool %s", dst.Name)
return nil
}
Loading