@@ -15,6 +15,12 @@ import (
1515const (
1616 InstanceTypeInstance = "instance"
1717 InstanceTypeBaremtal = "baremetal"
18+
19+ // nodeLabelDisableLifeCycle is a label for nulling cloudprovider.InstancesV2 interface
20+ nodeLabelDisableLifeCycle = "k8s.scw.cloud/disable-lifcycle"
21+
22+ // nodeAnnotationNodePublicIP is an annotation to override External-IP of a node
23+ nodeLabelNodePublicIP = "k8s.scw.cloud/node-public-ip"
1824)
1925
2026type Servers interface {
@@ -167,6 +173,10 @@ func (s *servers) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName
167173// InstanceExists returns true if the instance for the given node exists according to the cloud provider.
168174// Use the node.name or node.spec.providerID field to find the node in the cloud provider.
169175func (s * servers ) InstanceExists (ctx context.Context , node * v1.Node ) (bool , error ) {
176+ if _ , ok := node .Annotations [nodeLabelDisableLifeCycle ]; ok {
177+ return true , nil
178+ }
179+
170180 if node .Spec .ProviderID == "" {
171181 exists , err := s .instances .InstanceExists (ctx , node )
172182 if err != nil {
@@ -183,6 +193,10 @@ func (s *servers) InstanceExists(ctx context.Context, node *v1.Node) (bool, erro
183193// InstanceShutdown returns true if the instance is shutdown according to the cloud provider.
184194// Use the node.name or node.spec.providerID field to find the node in the cloud provider.
185195func (s * servers ) InstanceShutdown (ctx context.Context , node * v1.Node ) (bool , error ) {
196+ if _ , ok := node .Annotations [nodeLabelDisableLifeCycle ]; ok {
197+ return false , nil
198+ }
199+
186200 if node .Spec .ProviderID == "" {
187201 shutdown , err := s .instances .InstanceShutdown (ctx , node )
188202 if err == cloudprovider .InstanceNotFound {
@@ -197,6 +211,15 @@ func (s *servers) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, er
197211// translated into specific fields in the Node object on registration.
198212// Use the node.name or node.spec.providerID field to find the node in the cloud provider.
199213func (s * servers ) InstanceMetadata (ctx context.Context , node * v1.Node ) (* cloudprovider.InstanceMetadata , error ) {
214+ if address , ok := node .Annotations [nodeLabelNodePublicIP ]; ok {
215+ return & cloudprovider.InstanceMetadata {
216+ NodeAddresses : []v1.NodeAddress {{
217+ Type : v1 .NodeExternalIP ,
218+ Address : address ,
219+ }},
220+ }, nil
221+ }
222+
200223 if node .Spec .ProviderID == "" {
201224 metadata , err := s .instances .InstanceMetadata (ctx , node )
202225 if err == cloudprovider .InstanceNotFound {
0 commit comments