From cd66fd2f058df1bfc54ac72190b3c01287a0dbf9 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Tue, 15 Oct 2024 20:08:50 -0700 Subject: [PATCH 01/16] chore: swagger spec for nodebootstrapping GET and autogenerated client --- .../client/node_bootstrapping_client.go | 111 +++ .../node_bootstrapping_get_parameters.go | 210 ++++++ .../node_bootstrapping_get_responses.go | 187 +++++ .../client/operations/operations_client.go | 104 +++ .../models/agent_pool_security_profile.go | 56 ++ .../models/agent_pool_windows_profile.go | 56 ++ .../models/artifact_streaming_profile.go | 50 ++ .../models/azure_o_s_image_config.go | 59 ++ .../models/custom_kubelet_config.go | 89 +++ .../models/custom_linux_o_s_config.go | 169 +++++ pkg/provisionclients/models/enums.go | 63 ++ pkg/provisionclients/models/error.go | 59 ++ pkg/provisionclients/models/g_p_u_profile.go | 53 ++ .../models/node_bootstrapping.go | 191 +++++ .../models/provision_helper_values.go | 88 +++ .../models/provision_profile.go | 593 ++++++++++++++++ .../models/provision_values.go | 157 ++++ .../models/sig_image_config.go | 112 +++ .../models/sig_image_config_template.go | 59 ++ pkg/provisionclients/models/sysctl_config.go | 131 ++++ pkg/provisionclients/models/ulimit_config.go | 53 ++ .../swagger/nodebootstrapping.json | 671 ++++++++++++++++++ 22 files changed, 3321 insertions(+) create mode 100644 pkg/provisionclients/client/node_bootstrapping_client.go create mode 100644 pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go create mode 100644 pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go create mode 100644 pkg/provisionclients/client/operations/operations_client.go create mode 100644 pkg/provisionclients/models/agent_pool_security_profile.go create mode 100644 pkg/provisionclients/models/agent_pool_windows_profile.go create mode 100644 pkg/provisionclients/models/artifact_streaming_profile.go create mode 100644 pkg/provisionclients/models/azure_o_s_image_config.go create mode 100644 pkg/provisionclients/models/custom_kubelet_config.go create mode 100644 pkg/provisionclients/models/custom_linux_o_s_config.go create mode 100644 pkg/provisionclients/models/enums.go create mode 100644 pkg/provisionclients/models/error.go create mode 100644 pkg/provisionclients/models/g_p_u_profile.go create mode 100644 pkg/provisionclients/models/node_bootstrapping.go create mode 100644 pkg/provisionclients/models/provision_helper_values.go create mode 100644 pkg/provisionclients/models/provision_profile.go create mode 100644 pkg/provisionclients/models/provision_values.go create mode 100644 pkg/provisionclients/models/sig_image_config.go create mode 100644 pkg/provisionclients/models/sig_image_config_template.go create mode 100644 pkg/provisionclients/models/sysctl_config.go create mode 100644 pkg/provisionclients/models/ulimit_config.go create mode 100644 pkg/provisionclients/swagger/nodebootstrapping.json diff --git a/pkg/provisionclients/client/node_bootstrapping_client.go b/pkg/provisionclients/client/node_bootstrapping_client.go new file mode 100644 index 000000000..e74efc268 --- /dev/null +++ b/pkg/provisionclients/client/node_bootstrapping_client.go @@ -0,0 +1,111 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/client/operations" + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// Default node bootstrapping HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"https"} + +// NewHTTPClient creates a new node bootstrapping HTTP client. +func NewHTTPClient(formats strfmt.Registry) *NodeBootstrapping { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new node bootstrapping HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *NodeBootstrapping { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new node bootstrapping client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *NodeBootstrapping { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(NodeBootstrapping) + cli.Transport = transport + cli.Operations = operations.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// NodeBootstrapping is a client for node bootstrapping +type NodeBootstrapping struct { + Operations operations.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *NodeBootstrapping) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.Operations.SetTransport(transport) +} diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go new file mode 100644 index 000000000..e67f2f5e5 --- /dev/null +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go @@ -0,0 +1,210 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/models" +) + +// NewNodeBootstrappingGetParams creates a new NodeBootstrappingGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewNodeBootstrappingGetParams() *NodeBootstrappingGetParams { + return &NodeBootstrappingGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewNodeBootstrappingGetParamsWithTimeout creates a new NodeBootstrappingGetParams object +// with the ability to set a timeout on a request. +func NewNodeBootstrappingGetParamsWithTimeout(timeout time.Duration) *NodeBootstrappingGetParams { + return &NodeBootstrappingGetParams{ + timeout: timeout, + } +} + +// NewNodeBootstrappingGetParamsWithContext creates a new NodeBootstrappingGetParams object +// with the ability to set a context for a request. +func NewNodeBootstrappingGetParamsWithContext(ctx context.Context) *NodeBootstrappingGetParams { + return &NodeBootstrappingGetParams{ + Context: ctx, + } +} + +// NewNodeBootstrappingGetParamsWithHTTPClient creates a new NodeBootstrappingGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewNodeBootstrappingGetParamsWithHTTPClient(client *http.Client) *NodeBootstrappingGetParams { + return &NodeBootstrappingGetParams{ + HTTPClient: client, + } +} + +/* +NodeBootstrappingGetParams contains all the parameters to send to the API endpoint + + for the node bootstrapping get operation. + + Typically these are written to a http.Request. +*/ +type NodeBootstrappingGetParams struct { + + /* Parameters. + + Values required to determine NodeBootstrapping values. + */ + Parameters *models.ProvisionValues + + // ResourceGroupName. + ResourceGroupName string + + // ResourceName. + ResourceName string + + // SubscriptionID. + SubscriptionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the node bootstrapping get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *NodeBootstrappingGetParams) WithDefaults() *NodeBootstrappingGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the node bootstrapping get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *NodeBootstrappingGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithTimeout(timeout time.Duration) *NodeBootstrappingGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithContext(ctx context.Context) *NodeBootstrappingGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithHTTPClient(client *http.Client) *NodeBootstrappingGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithParameters adds the parameters to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithParameters(parameters *models.ProvisionValues) *NodeBootstrappingGetParams { + o.SetParameters(parameters) + return o +} + +// SetParameters adds the parameters to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetParameters(parameters *models.ProvisionValues) { + o.Parameters = parameters +} + +// WithResourceGroupName adds the resourceGroupName to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithResourceGroupName(resourceGroupName string) *NodeBootstrappingGetParams { + o.SetResourceGroupName(resourceGroupName) + return o +} + +// SetResourceGroupName adds the resourceGroupName to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetResourceGroupName(resourceGroupName string) { + o.ResourceGroupName = resourceGroupName +} + +// WithResourceName adds the resourceName to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithResourceName(resourceName string) *NodeBootstrappingGetParams { + o.SetResourceName(resourceName) + return o +} + +// SetResourceName adds the resourceName to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetResourceName(resourceName string) { + o.ResourceName = resourceName +} + +// WithSubscriptionID adds the subscriptionID to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) WithSubscriptionID(subscriptionID string) *NodeBootstrappingGetParams { + o.SetSubscriptionID(subscriptionID) + return o +} + +// SetSubscriptionID adds the subscriptionId to the node bootstrapping get params +func (o *NodeBootstrappingGetParams) SetSubscriptionID(subscriptionID string) { + o.SubscriptionID = subscriptionID +} + +// WriteToRequest writes these params to a swagger request +func (o *NodeBootstrappingGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Parameters != nil { + if err := r.SetBodyParam(o.Parameters); err != nil { + return err + } + } + + // path param resourceGroupName + if err := r.SetPathParam("resourceGroupName", o.ResourceGroupName); err != nil { + return err + } + + // path param resourceName + if err := r.SetPathParam("resourceName", o.ResourceName); err != nil { + return err + } + + // path param subscriptionId + if err := r.SetPathParam("subscriptionId", o.SubscriptionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go new file mode 100644 index 000000000..3f5dc19b0 --- /dev/null +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go @@ -0,0 +1,187 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/models" +) + +// NodeBootstrappingGetReader is a Reader for the NodeBootstrappingGet structure. +type NodeBootstrappingGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *NodeBootstrappingGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewNodeBootstrappingGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewNodeBootstrappingGetDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewNodeBootstrappingGetOK creates a NodeBootstrappingGetOK with default headers values +func NewNodeBootstrappingGetOK() *NodeBootstrappingGetOK { + return &NodeBootstrappingGetOK{} +} + +/* +NodeBootstrappingGetOK describes a response with status code 200, with default header values. + +OK +*/ +type NodeBootstrappingGetOK struct { + Payload *models.NodeBootstrapping +} + +// IsSuccess returns true when this node bootstrapping get o k response has a 2xx status code +func (o *NodeBootstrappingGetOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this node bootstrapping get o k response has a 3xx status code +func (o *NodeBootstrappingGetOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this node bootstrapping get o k response has a 4xx status code +func (o *NodeBootstrappingGetOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this node bootstrapping get o k response has a 5xx status code +func (o *NodeBootstrappingGetOK) IsServerError() bool { + return false +} + +// IsCode returns true when this node bootstrapping get o k response a status code equal to that given +func (o *NodeBootstrappingGetOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the node bootstrapping get o k response +func (o *NodeBootstrappingGetOK) Code() int { + return 200 +} + +func (o *NodeBootstrappingGetOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping][%d] nodeBootstrappingGetOK %s", 200, payload) +} + +func (o *NodeBootstrappingGetOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping][%d] nodeBootstrappingGetOK %s", 200, payload) +} + +func (o *NodeBootstrappingGetOK) GetPayload() *models.NodeBootstrapping { + return o.Payload +} + +func (o *NodeBootstrappingGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NodeBootstrapping) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewNodeBootstrappingGetDefault creates a NodeBootstrappingGetDefault with default headers values +func NewNodeBootstrappingGetDefault(code int) *NodeBootstrappingGetDefault { + return &NodeBootstrappingGetDefault{ + _statusCode: code, + } +} + +/* +NodeBootstrappingGetDefault describes a response with status code -1, with default header values. + +Error response describing why the operation failed. +*/ +type NodeBootstrappingGetDefault struct { + _statusCode int + + Payload *models.Error +} + +// IsSuccess returns true when this node bootstrapping get default response has a 2xx status code +func (o *NodeBootstrappingGetDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this node bootstrapping get default response has a 3xx status code +func (o *NodeBootstrappingGetDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this node bootstrapping get default response has a 4xx status code +func (o *NodeBootstrappingGetDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this node bootstrapping get default response has a 5xx status code +func (o *NodeBootstrappingGetDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this node bootstrapping get default response a status code equal to that given +func (o *NodeBootstrappingGetDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the node bootstrapping get default response +func (o *NodeBootstrappingGetDefault) Code() int { + return o._statusCode +} + +func (o *NodeBootstrappingGetDefault) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping][%d] NodeBootstrapping_Get default %s", o._statusCode, payload) +} + +func (o *NodeBootstrappingGetDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping][%d] NodeBootstrapping_Get default %s", o._statusCode, payload) +} + +func (o *NodeBootstrappingGetDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/provisionclients/client/operations/operations_client.go b/pkg/provisionclients/client/operations/operations_client.go new file mode 100644 index 000000000..a0166e378 --- /dev/null +++ b/pkg/provisionclients/client/operations/operations_client.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// New creates a new operations API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +// New creates a new operations API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new operations API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + +/* +Client for operations API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + NodeBootstrappingGet(params *NodeBootstrappingGetParams, opts ...ClientOption) (*NodeBootstrappingGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +NodeBootstrappingGet gets node bootstrapping values for a specified provisioning configuration with secrets redacted + +Gets NodeBootstrapping values for a specified provisioning configuration, with secrets redacted. +*/ +func (a *Client) NodeBootstrappingGet(params *NodeBootstrappingGetParams, opts ...ClientOption) (*NodeBootstrappingGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewNodeBootstrappingGetParams() + } + op := &runtime.ClientOperation{ + ID: "NodeBootstrapping_Get", + Method: "GET", + PathPattern: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &NodeBootstrappingGetReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*NodeBootstrappingGetOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*NodeBootstrappingGetDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/pkg/provisionclients/models/agent_pool_security_profile.go b/pkg/provisionclients/models/agent_pool_security_profile.go new file mode 100644 index 000000000..17250c1f5 --- /dev/null +++ b/pkg/provisionclients/models/agent_pool_security_profile.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AgentPoolSecurityProfile agent pool security profile +// +// swagger:model AgentPoolSecurityProfile +type AgentPoolSecurityProfile struct { + + // enable secure boot + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + + // enable v t p m + EnableVTPM *bool `json:"enableVTPM,omitempty"` + + // ssh access + SSHAccess *int32 `json:"sshAccess,omitempty"` +} + +// Validate validates this agent pool security profile +func (m *AgentPoolSecurityProfile) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this agent pool security profile based on context it is used +func (m *AgentPoolSecurityProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AgentPoolSecurityProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AgentPoolSecurityProfile) UnmarshalBinary(b []byte) error { + var res AgentPoolSecurityProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/agent_pool_windows_profile.go b/pkg/provisionclients/models/agent_pool_windows_profile.go new file mode 100644 index 000000000..4ced2fdc2 --- /dev/null +++ b/pkg/provisionclients/models/agent_pool_windows_profile.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AgentPoolWindowsProfile agent pool windows profile +// +// swagger:model AgentPoolWindowsProfile +type AgentPoolWindowsProfile struct { + + // containerd package + ContainerdPackage *string `json:"containerdPackage,omitempty"` + + // disable outbound nat + DisableOutboundNat *bool `json:"disableOutboundNat,omitempty"` + + // enable next gen networking + EnableNextGenNetworking *bool `json:"enableNextGenNetworking,omitempty"` +} + +// Validate validates this agent pool windows profile +func (m *AgentPoolWindowsProfile) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this agent pool windows profile based on context it is used +func (m *AgentPoolWindowsProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AgentPoolWindowsProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AgentPoolWindowsProfile) UnmarshalBinary(b []byte) error { + var res AgentPoolWindowsProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/artifact_streaming_profile.go b/pkg/provisionclients/models/artifact_streaming_profile.go new file mode 100644 index 000000000..73a51b15a --- /dev/null +++ b/pkg/provisionclients/models/artifact_streaming_profile.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ArtifactStreamingProfile artifact streaming profile +// +// swagger:model ArtifactStreamingProfile +type ArtifactStreamingProfile struct { + + // enabled + Enabled *bool `json:"enabled,omitempty"` +} + +// Validate validates this artifact streaming profile +func (m *ArtifactStreamingProfile) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this artifact streaming profile based on context it is used +func (m *ArtifactStreamingProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ArtifactStreamingProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ArtifactStreamingProfile) UnmarshalBinary(b []byte) error { + var res ArtifactStreamingProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/azure_o_s_image_config.go b/pkg/provisionclients/models/azure_o_s_image_config.go new file mode 100644 index 000000000..04190131e --- /dev/null +++ b/pkg/provisionclients/models/azure_o_s_image_config.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AzureOSImageConfig azure o s image config +// +// swagger:model AzureOSImageConfig +type AzureOSImageConfig struct { + + // image offer + ImageOffer *string `json:"imageOffer,omitempty"` + + // image publisher + ImagePublisher *string `json:"imagePublisher,omitempty"` + + // image sku + ImageSku *string `json:"imageSku,omitempty"` + + // image version + ImageVersion *string `json:"imageVersion,omitempty"` +} + +// Validate validates this azure o s image config +func (m *AzureOSImageConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this azure o s image config based on context it is used +func (m *AzureOSImageConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AzureOSImageConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AzureOSImageConfig) UnmarshalBinary(b []byte) error { + var res AzureOSImageConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/custom_kubelet_config.go b/pkg/provisionclients/models/custom_kubelet_config.go new file mode 100644 index 000000000..637030286 --- /dev/null +++ b/pkg/provisionclients/models/custom_kubelet_config.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CustomKubeletConfig custom kubelet config +// +// swagger:model CustomKubeletConfig +type CustomKubeletConfig struct { + + // allowed unsafe sysctls + AllowedUnsafeSysctls []string `json:"allowedUnsafeSysctls"` + + // container log max files + ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty"` + + // container log max size m b + ContainerLogMaxSizeMB *int32 `json:"containerLogMaxSizeMB,omitempty"` + + // cpu cfs quota + CPUCfsQuota *bool `json:"cpuCfsQuota,omitempty"` + + // cpu cfs quota period + CPUCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"` + + // cpu manager policy + CPUManagerPolicy *string `json:"cpuManagerPolicy,omitempty"` + + // cpu reserved + CPUReserved *int32 `json:"cpuReserved,omitempty"` + + // fail swap on + FailSwapOn *bool `json:"failSwapOn,omitempty"` + + // image gc high threshold + ImageGcHighThreshold *int32 `json:"imageGcHighThreshold,omitempty"` + + // image gc low threshold + ImageGcLowThreshold *int32 `json:"imageGcLowThreshold,omitempty"` + + // memory reserved + MemoryReserved *int32 `json:"memoryReserved,omitempty"` + + // pod max pids + PodMaxPids *int32 `json:"podMaxPids,omitempty"` + + // seccomp default + SeccompDefault *string `json:"seccompDefault,omitempty"` + + // topology manager policy + TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"` +} + +// Validate validates this custom kubelet config +func (m *CustomKubeletConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this custom kubelet config based on context it is used +func (m *CustomKubeletConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CustomKubeletConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CustomKubeletConfig) UnmarshalBinary(b []byte) error { + var res CustomKubeletConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/custom_linux_o_s_config.go b/pkg/provisionclients/models/custom_linux_o_s_config.go new file mode 100644 index 000000000..325149255 --- /dev/null +++ b/pkg/provisionclients/models/custom_linux_o_s_config.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CustomLinuxOSConfig custom linux o s config +// +// swagger:model CustomLinuxOSConfig +type CustomLinuxOSConfig struct { + + // swap file size m b + SwapFileSizeMB *int32 `json:"swapFileSizeMB,omitempty"` + + // sysctls + Sysctls *SysctlConfig `json:"sysctls,omitempty"` + + // transparent huge page defrag + TransparentHugePageDefrag *string `json:"transparentHugePageDefrag,omitempty"` + + // transparent huge page enabled + TransparentHugePageEnabled *string `json:"transparentHugePageEnabled,omitempty"` + + // ulimits + Ulimits *UlimitConfig `json:"ulimits,omitempty"` +} + +// Validate validates this custom linux o s config +func (m *CustomLinuxOSConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSysctls(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUlimits(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CustomLinuxOSConfig) validateSysctls(formats strfmt.Registry) error { + if swag.IsZero(m.Sysctls) { // not required + return nil + } + + if m.Sysctls != nil { + if err := m.Sysctls.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sysctls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sysctls") + } + return err + } + } + + return nil +} + +func (m *CustomLinuxOSConfig) validateUlimits(formats strfmt.Registry) error { + if swag.IsZero(m.Ulimits) { // not required + return nil + } + + if m.Ulimits != nil { + if err := m.Ulimits.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ulimits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ulimits") + } + return err + } + } + + return nil +} + +// ContextValidate validate this custom linux o s config based on the context it is used +func (m *CustomLinuxOSConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSysctls(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateUlimits(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CustomLinuxOSConfig) contextValidateSysctls(ctx context.Context, formats strfmt.Registry) error { + + if m.Sysctls != nil { + + if swag.IsZero(m.Sysctls) { // not required + return nil + } + + if err := m.Sysctls.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sysctls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sysctls") + } + return err + } + } + + return nil +} + +func (m *CustomLinuxOSConfig) contextValidateUlimits(ctx context.Context, formats strfmt.Registry) error { + + if m.Ulimits != nil { + + if swag.IsZero(m.Ulimits) { // not required + return nil + } + + if err := m.Ulimits.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ulimits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ulimits") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CustomLinuxOSConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CustomLinuxOSConfig) UnmarshalBinary(b []byte) error { + var res CustomLinuxOSConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/enums.go b/pkg/provisionclients/models/enums.go new file mode 100644 index 000000000..ea5406512 --- /dev/null +++ b/pkg/provisionclients/models/enums.go @@ -0,0 +1,63 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package models + +const ( + OSType_Unspecified int32 = 0 + OSType_Windows int32 = 1 + OSType_Linux int32 = 2 +) + +const ( + OSSKU_Unspecified int32 = 0 + OSSKU_Ubuntu int32 = 1 + OSSKU_AzureLinux int32 = 7 + OSSKU_Windows2019 int32 = 3 + OSSKU_Windows2022 int32 = 4 + OSSKU_WindowsAnnual int32 = 8 +) + +const ( + KubeletDiskType_Unspecified int32 = 0 + KubeletDiskType_OS int32 = 1 + KubeletDiskType_Temporary int32 = 2 +) + +const ( + AgentPoolMode_Unspecified int32 = 0 + AgentPoolMode_System int32 = 1 + AgentPoolMode_User int32 = 2 +) + +const ( + GPUInstanceProfile_Unspecified int32 = 0 +) + +const ( + WorkloadRuntime_Unspecified int32 = 0 +) + +const ( + SSHAccess_LocalUser int32 = 0 + SSHAccess_Disabled int32 = 1 +) + +const ( + DriverType_Unspecified int32 = 0 + DriverType_GRID int32 = 2 + DriverType_CUDA int32 = 3 +) diff --git a/pkg/provisionclients/models/error.go b/pkg/provisionclients/models/error.go new file mode 100644 index 000000000..f7389db90 --- /dev/null +++ b/pkg/provisionclients/models/error.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Error error +// +// swagger:model Error +type Error struct { + + // category + Category string `json:"category,omitempty"` + + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // subcode + Subcode string `json:"subcode,omitempty"` +} + +// Validate validates this error +func (m *Error) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this error based on context it is used +func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Error) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Error) UnmarshalBinary(b []byte) error { + var res Error + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/g_p_u_profile.go b/pkg/provisionclients/models/g_p_u_profile.go new file mode 100644 index 000000000..e664ca8fd --- /dev/null +++ b/pkg/provisionclients/models/g_p_u_profile.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GPUProfile g p u profile +// +// swagger:model GPUProfile +type GPUProfile struct { + + // driver type + DriverType *int32 `json:"driverType,omitempty"` + + // install g p u driver + InstallGPUDriver *bool `json:"installGPUDriver,omitempty"` +} + +// Validate validates this g p u profile +func (m *GPUProfile) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this g p u profile based on context it is used +func (m *GPUProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *GPUProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *GPUProfile) UnmarshalBinary(b []byte) error { + var res GPUProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/node_bootstrapping.go b/pkg/provisionclients/models/node_bootstrapping.go new file mode 100644 index 000000000..44cc9ae2c --- /dev/null +++ b/pkg/provisionclients/models/node_bootstrapping.go @@ -0,0 +1,191 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NodeBootstrapping node bootstrapping +// +// swagger:model NodeBootstrapping +type NodeBootstrapping struct { + + // cse + // Required: true + Cse *string `json:"cse"` + + // custom data + // Required: true + CustomData *string `json:"customData"` + + // os image config + // Required: true + OsImageConfig *AzureOSImageConfig `json:"osImageConfig"` + + // sig image config + // Required: true + SigImageConfig *SigImageConfig `json:"sigImageConfig"` +} + +// Validate validates this node bootstrapping +func (m *NodeBootstrapping) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCse(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCustomData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsImageConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSigImageConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NodeBootstrapping) validateCse(formats strfmt.Registry) error { + + if err := validate.Required("cse", "body", m.Cse); err != nil { + return err + } + + return nil +} + +func (m *NodeBootstrapping) validateCustomData(formats strfmt.Registry) error { + + if err := validate.Required("customData", "body", m.CustomData); err != nil { + return err + } + + return nil +} + +func (m *NodeBootstrapping) validateOsImageConfig(formats strfmt.Registry) error { + + if err := validate.Required("osImageConfig", "body", m.OsImageConfig); err != nil { + return err + } + + if m.OsImageConfig != nil { + if err := m.OsImageConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("osImageConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("osImageConfig") + } + return err + } + } + + return nil +} + +func (m *NodeBootstrapping) validateSigImageConfig(formats strfmt.Registry) error { + + if err := validate.Required("sigImageConfig", "body", m.SigImageConfig); err != nil { + return err + } + + if m.SigImageConfig != nil { + if err := m.SigImageConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sigImageConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sigImageConfig") + } + return err + } + } + + return nil +} + +// ContextValidate validate this node bootstrapping based on the context it is used +func (m *NodeBootstrapping) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOsImageConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSigImageConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NodeBootstrapping) contextValidateOsImageConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.OsImageConfig != nil { + + if err := m.OsImageConfig.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("osImageConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("osImageConfig") + } + return err + } + } + + return nil +} + +func (m *NodeBootstrapping) contextValidateSigImageConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.SigImageConfig != nil { + + if err := m.SigImageConfig.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sigImageConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sigImageConfig") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NodeBootstrapping) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NodeBootstrapping) UnmarshalBinary(b []byte) error { + var res NodeBootstrapping + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/provision_helper_values.go b/pkg/provisionclients/models/provision_helper_values.go new file mode 100644 index 000000000..a06e825a5 --- /dev/null +++ b/pkg/provisionclients/models/provision_helper_values.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProvisionHelperValues provision helper values +// +// swagger:model ProvisionHelperValues +type ProvisionHelperValues struct { + + // sku CPU + // Required: true + SkuCPU *float64 `json:"skuCPU"` + + // sku memory + // Required: true + SkuMemory *float64 `json:"skuMemory"` +} + +// Validate validates this provision helper values +func (m *ProvisionHelperValues) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSkuCPU(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSkuMemory(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProvisionHelperValues) validateSkuCPU(formats strfmt.Registry) error { + + if err := validate.Required("skuCPU", "body", m.SkuCPU); err != nil { + return err + } + + return nil +} + +func (m *ProvisionHelperValues) validateSkuMemory(formats strfmt.Registry) error { + + if err := validate.Required("skuMemory", "body", m.SkuMemory); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this provision helper values based on context it is used +func (m *ProvisionHelperValues) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProvisionHelperValues) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProvisionHelperValues) UnmarshalBinary(b []byte) error { + var res ProvisionHelperValues + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/provision_profile.go b/pkg/provisionclients/models/provision_profile.go new file mode 100644 index 000000000..f93fee777 --- /dev/null +++ b/pkg/provisionclients/models/provision_profile.go @@ -0,0 +1,593 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProvisionProfile provision profile +// +// swagger:model ProvisionProfile +type ProvisionProfile struct { + + // agent pool windows profile + AgentPoolWindowsProfile *AgentPoolWindowsProfile `json:"agentPoolWindowsProfile,omitempty"` + + // architecture + // Required: true + Architecture *string `json:"architecture"` + + // artifact streaming profile + ArtifactStreamingProfile *ArtifactStreamingProfile `json:"artifactStreamingProfile,omitempty"` + + // custom kubelet config + CustomKubeletConfig *CustomKubeletConfig `json:"customKubeletConfig,omitempty"` + + // custom linux o s config + CustomLinuxOSConfig *CustomLinuxOSConfig `json:"customLinuxOSConfig,omitempty"` + + // custom node labels + CustomNodeLabels map[string]string `json:"customNodeLabels,omitempty"` + + // distro + // Required: true + Distro *string `json:"distro"` + + // enable f IP s + EnableFIPS *bool `json:"enableFIPS,omitempty"` + + // gpu instance profile + GpuInstanceProfile *int32 `json:"gpuInstanceProfile,omitempty"` + + // gpu profile + GpuProfile *GPUProfile `json:"gpuProfile,omitempty"` + + // kubelet disk type + KubeletDiskType *int32 `json:"kubeletDiskType,omitempty"` + + // max pods + // Required: true + MaxPods *int32 `json:"maxPods"` + + // message of the day + MessageOfTheDay *string `json:"messageOfTheDay,omitempty"` + + // mode + // Required: true + Mode *int32 `json:"mode"` + + // name + // Required: true + Name *string `json:"name"` + + // node initialization taints + NodeInitializationTaints []string `json:"nodeInitializationTaints"` + + // node taints + NodeTaints []string `json:"nodeTaints"` + + // orchestrator version + // Required: true + OrchestratorVersion *string `json:"orchestratorVersion"` + + // os sku + // Required: true + OsSku *int32 `json:"osSku"` + + // os type + // Required: true + OsType *int32 `json:"osType"` + + // security profile + SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"` + + // storage profile + // Required: true + StorageProfile *string `json:"storageProfile"` + + // vm size + // Required: true + VMSize *string `json:"vmSize"` + + // vnet cidrs + // Required: true + VnetCidrs []string `json:"vnetCidrs"` + + // vnet subnet ID + // Required: true + VnetSubnetID *string `json:"vnetSubnetID"` + + // workload runtime + WorkloadRuntime *int32 `json:"workloadRuntime,omitempty"` +} + +// Validate validates this provision profile +func (m *ProvisionProfile) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAgentPoolWindowsProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateArchitecture(formats); err != nil { + res = append(res, err) + } + + if err := m.validateArtifactStreamingProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCustomKubeletConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCustomLinuxOSConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDistro(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGpuProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMaxPods(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOrchestratorVersion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsSku(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSecurityProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVMSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVnetCidrs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVnetSubnetID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProvisionProfile) validateAgentPoolWindowsProfile(formats strfmt.Registry) error { + if swag.IsZero(m.AgentPoolWindowsProfile) { // not required + return nil + } + + if m.AgentPoolWindowsProfile != nil { + if err := m.AgentPoolWindowsProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("agentPoolWindowsProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("agentPoolWindowsProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateArchitecture(formats strfmt.Registry) error { + + if err := validate.Required("architecture", "body", m.Architecture); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateArtifactStreamingProfile(formats strfmt.Registry) error { + if swag.IsZero(m.ArtifactStreamingProfile) { // not required + return nil + } + + if m.ArtifactStreamingProfile != nil { + if err := m.ArtifactStreamingProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("artifactStreamingProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("artifactStreamingProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateCustomKubeletConfig(formats strfmt.Registry) error { + if swag.IsZero(m.CustomKubeletConfig) { // not required + return nil + } + + if m.CustomKubeletConfig != nil { + if err := m.CustomKubeletConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customKubeletConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customKubeletConfig") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateCustomLinuxOSConfig(formats strfmt.Registry) error { + if swag.IsZero(m.CustomLinuxOSConfig) { // not required + return nil + } + + if m.CustomLinuxOSConfig != nil { + if err := m.CustomLinuxOSConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customLinuxOSConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customLinuxOSConfig") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateDistro(formats strfmt.Registry) error { + + if err := validate.Required("distro", "body", m.Distro); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateGpuProfile(formats strfmt.Registry) error { + if swag.IsZero(m.GpuProfile) { // not required + return nil + } + + if m.GpuProfile != nil { + if err := m.GpuProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gpuProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gpuProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateMaxPods(formats strfmt.Registry) error { + + if err := validate.Required("maxPods", "body", m.MaxPods); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateMode(formats strfmt.Registry) error { + + if err := validate.Required("mode", "body", m.Mode); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateOrchestratorVersion(formats strfmt.Registry) error { + + if err := validate.Required("orchestratorVersion", "body", m.OrchestratorVersion); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateOsSku(formats strfmt.Registry) error { + + if err := validate.Required("osSku", "body", m.OsSku); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateOsType(formats strfmt.Registry) error { + + if err := validate.Required("osType", "body", m.OsType); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateSecurityProfile(formats strfmt.Registry) error { + if swag.IsZero(m.SecurityProfile) { // not required + return nil + } + + if m.SecurityProfile != nil { + if err := m.SecurityProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("securityProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("securityProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) validateStorageProfile(formats strfmt.Registry) error { + + if err := validate.Required("storageProfile", "body", m.StorageProfile); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateVMSize(formats strfmt.Registry) error { + + if err := validate.Required("vmSize", "body", m.VMSize); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateVnetCidrs(formats strfmt.Registry) error { + + if err := validate.Required("vnetCidrs", "body", m.VnetCidrs); err != nil { + return err + } + + return nil +} + +func (m *ProvisionProfile) validateVnetSubnetID(formats strfmt.Registry) error { + + if err := validate.Required("vnetSubnetID", "body", m.VnetSubnetID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this provision profile based on the context it is used +func (m *ProvisionProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAgentPoolWindowsProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateArtifactStreamingProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCustomKubeletConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCustomLinuxOSConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateGpuProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSecurityProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProvisionProfile) contextValidateAgentPoolWindowsProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.AgentPoolWindowsProfile != nil { + + if swag.IsZero(m.AgentPoolWindowsProfile) { // not required + return nil + } + + if err := m.AgentPoolWindowsProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("agentPoolWindowsProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("agentPoolWindowsProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) contextValidateArtifactStreamingProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.ArtifactStreamingProfile != nil { + + if swag.IsZero(m.ArtifactStreamingProfile) { // not required + return nil + } + + if err := m.ArtifactStreamingProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("artifactStreamingProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("artifactStreamingProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) contextValidateCustomKubeletConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.CustomKubeletConfig != nil { + + if swag.IsZero(m.CustomKubeletConfig) { // not required + return nil + } + + if err := m.CustomKubeletConfig.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customKubeletConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customKubeletConfig") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) contextValidateCustomLinuxOSConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.CustomLinuxOSConfig != nil { + + if swag.IsZero(m.CustomLinuxOSConfig) { // not required + return nil + } + + if err := m.CustomLinuxOSConfig.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customLinuxOSConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customLinuxOSConfig") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) contextValidateGpuProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.GpuProfile != nil { + + if swag.IsZero(m.GpuProfile) { // not required + return nil + } + + if err := m.GpuProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gpuProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gpuProfile") + } + return err + } + } + + return nil +} + +func (m *ProvisionProfile) contextValidateSecurityProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.SecurityProfile != nil { + + if swag.IsZero(m.SecurityProfile) { // not required + return nil + } + + if err := m.SecurityProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("securityProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("securityProfile") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProvisionProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProvisionProfile) UnmarshalBinary(b []byte) error { + var res ProvisionProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/provision_values.go b/pkg/provisionclients/models/provision_values.go new file mode 100644 index 000000000..aa1473e6f --- /dev/null +++ b/pkg/provisionclients/models/provision_values.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProvisionValues provision values +// +// swagger:model ProvisionValues +type ProvisionValues struct { + + // provision helper values + // Required: true + ProvisionHelperValues *ProvisionHelperValues `json:"provisionHelperValues"` + + // provision profile + // Required: true + ProvisionProfile *ProvisionProfile `json:"provisionProfile"` +} + +// Validate validates this provision values +func (m *ProvisionValues) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProvisionHelperValues(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProvisionProfile(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProvisionValues) validateProvisionHelperValues(formats strfmt.Registry) error { + + if err := validate.Required("provisionHelperValues", "body", m.ProvisionHelperValues); err != nil { + return err + } + + if m.ProvisionHelperValues != nil { + if err := m.ProvisionHelperValues.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provisionHelperValues") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("provisionHelperValues") + } + return err + } + } + + return nil +} + +func (m *ProvisionValues) validateProvisionProfile(formats strfmt.Registry) error { + + if err := validate.Required("provisionProfile", "body", m.ProvisionProfile); err != nil { + return err + } + + if m.ProvisionProfile != nil { + if err := m.ProvisionProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provisionProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("provisionProfile") + } + return err + } + } + + return nil +} + +// ContextValidate validate this provision values based on the context it is used +func (m *ProvisionValues) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProvisionHelperValues(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProvisionProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProvisionValues) contextValidateProvisionHelperValues(ctx context.Context, formats strfmt.Registry) error { + + if m.ProvisionHelperValues != nil { + + if err := m.ProvisionHelperValues.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provisionHelperValues") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("provisionHelperValues") + } + return err + } + } + + return nil +} + +func (m *ProvisionValues) contextValidateProvisionProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.ProvisionProfile != nil { + + if err := m.ProvisionProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provisionProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("provisionProfile") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProvisionValues) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProvisionValues) UnmarshalBinary(b []byte) error { + var res ProvisionValues + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/sig_image_config.go b/pkg/provisionclients/models/sig_image_config.go new file mode 100644 index 000000000..9379d2420 --- /dev/null +++ b/pkg/provisionclients/models/sig_image_config.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SigImageConfig sig image config +// +// swagger:model SigImageConfig +type SigImageConfig struct { + + // sig image config template + SigImageConfigTemplate *SigImageConfigTemplate `json:"sigImageConfigTemplate,omitempty"` + + // subscription ID + SubscriptionID *string `json:"subscriptionID,omitempty"` +} + +// Validate validates this sig image config +func (m *SigImageConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSigImageConfigTemplate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SigImageConfig) validateSigImageConfigTemplate(formats strfmt.Registry) error { + if swag.IsZero(m.SigImageConfigTemplate) { // not required + return nil + } + + if m.SigImageConfigTemplate != nil { + if err := m.SigImageConfigTemplate.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sigImageConfigTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sigImageConfigTemplate") + } + return err + } + } + + return nil +} + +// ContextValidate validate this sig image config based on the context it is used +func (m *SigImageConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSigImageConfigTemplate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SigImageConfig) contextValidateSigImageConfigTemplate(ctx context.Context, formats strfmt.Registry) error { + + if m.SigImageConfigTemplate != nil { + + if swag.IsZero(m.SigImageConfigTemplate) { // not required + return nil + } + + if err := m.SigImageConfigTemplate.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sigImageConfigTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sigImageConfigTemplate") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SigImageConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SigImageConfig) UnmarshalBinary(b []byte) error { + var res SigImageConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/sig_image_config_template.go b/pkg/provisionclients/models/sig_image_config_template.go new file mode 100644 index 000000000..3c2e8fc98 --- /dev/null +++ b/pkg/provisionclients/models/sig_image_config_template.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SigImageConfigTemplate sig image config template +// +// swagger:model SigImageConfigTemplate +type SigImageConfigTemplate struct { + + // definition + Definition *string `json:"definition,omitempty"` + + // gallery + Gallery *string `json:"gallery,omitempty"` + + // resource group + ResourceGroup *string `json:"resourceGroup,omitempty"` + + // version + Version *string `json:"version,omitempty"` +} + +// Validate validates this sig image config template +func (m *SigImageConfigTemplate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this sig image config template based on context it is used +func (m *SigImageConfigTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SigImageConfigTemplate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SigImageConfigTemplate) UnmarshalBinary(b []byte) error { + var res SigImageConfigTemplate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/sysctl_config.go b/pkg/provisionclients/models/sysctl_config.go new file mode 100644 index 000000000..00ab75483 --- /dev/null +++ b/pkg/provisionclients/models/sysctl_config.go @@ -0,0 +1,131 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SysctlConfig sysctl config +// +// swagger:model SysctlConfig +type SysctlConfig struct { + + // fs aio max nr + FsAioMaxNr *int32 `json:"fsAioMaxNr,omitempty"` + + // fs file max + FsFileMax *int32 `json:"fsFileMax,omitempty"` + + // fs inotify max user watches + FsInotifyMaxUserWatches *int32 `json:"fsInotifyMaxUserWatches,omitempty"` + + // fs nr open + FsNrOpen *int32 `json:"fsNrOpen,omitempty"` + + // kernel threads max + KernelThreadsMax *int32 `json:"kernelThreadsMax,omitempty"` + + // net core netdev max backlog + NetCoreNetdevMaxBacklog *int32 `json:"netCoreNetdevMaxBacklog,omitempty"` + + // net core optmem max + NetCoreOptmemMax *int32 `json:"netCoreOptmemMax,omitempty"` + + // net core rmem default + NetCoreRmemDefault *int32 `json:"netCoreRmemDefault,omitempty"` + + // net core rmem max + NetCoreRmemMax *int32 `json:"netCoreRmemMax,omitempty"` + + // net core somaxconn + NetCoreSomaxconn *int32 `json:"netCoreSomaxconn,omitempty"` + + // net core wmem default + NetCoreWmemDefault *int32 `json:"netCoreWmemDefault,omitempty"` + + // net core wmem max + NetCoreWmemMax *int32 `json:"netCoreWmemMax,omitempty"` + + // net Ipv4 Ip local port range + NetIPV4IPLocalPortRange *string `json:"netIpv4IpLocalPortRange,omitempty"` + + // net Ipv4 neigh default gc thresh1 + NetIPV4NeighDefaultGcThresh1 *int32 `json:"netIpv4NeighDefaultGcThresh1,omitempty"` + + // net Ipv4 neigh default gc thresh2 + NetIPV4NeighDefaultGcThresh2 *int32 `json:"netIpv4NeighDefaultGcThresh2,omitempty"` + + // net Ipv4 neigh default gc thresh3 + NetIPV4NeighDefaultGcThresh3 *int32 `json:"netIpv4NeighDefaultGcThresh3,omitempty"` + + // net Ipv4 Tcp fin timeout + NetIPV4TCPFinTimeout *int32 `json:"netIpv4TcpFinTimeout,omitempty"` + + // net Ipv4 Tcp keepalive probes + NetIPV4TCPKeepaliveProbes *int32 `json:"netIpv4TcpKeepaliveProbes,omitempty"` + + // net Ipv4 Tcp keepalive time + NetIPV4TCPKeepaliveTime *int32 `json:"netIpv4TcpKeepaliveTime,omitempty"` + + // net Ipv4 Tcp max syn backlog + NetIPV4TCPMaxSynBacklog *int32 `json:"netIpv4TcpMaxSynBacklog,omitempty"` + + // net Ipv4 Tcp max tw buckets + NetIPV4TCPMaxTwBuckets *int32 `json:"netIpv4TcpMaxTwBuckets,omitempty"` + + // net Ipv4 Tcp tw reuse + NetIPV4TCPTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"` + + // net Ipv4 tcpkeepalive intvl + NetIPV4TcpkeepaliveIntvl *int32 `json:"netIpv4TcpkeepaliveIntvl,omitempty"` + + // net netfilter nf conntrack buckets + NetNetfilterNfConntrackBuckets *int32 `json:"netNetfilterNfConntrackBuckets,omitempty"` + + // net netfilter nf conntrack max + NetNetfilterNfConntrackMax *int32 `json:"netNetfilterNfConntrackMax,omitempty"` + + // vm max map count + VMMaxMapCount *int32 `json:"vmMaxMapCount,omitempty"` + + // vm swappiness + VMSwappiness *int32 `json:"vmSwappiness,omitempty"` + + // vm vfs cache pressure + VMVfsCachePressure *int32 `json:"vmVfsCachePressure,omitempty"` +} + +// Validate validates this sysctl config +func (m *SysctlConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this sysctl config based on context it is used +func (m *SysctlConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SysctlConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SysctlConfig) UnmarshalBinary(b []byte) error { + var res SysctlConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/models/ulimit_config.go b/pkg/provisionclients/models/ulimit_config.go new file mode 100644 index 000000000..c36532f50 --- /dev/null +++ b/pkg/provisionclients/models/ulimit_config.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UlimitConfig ulimit config +// +// swagger:model UlimitConfig +type UlimitConfig struct { + + // max locked memory + MaxLockedMemory *string `json:"maxLockedMemory,omitempty"` + + // no file + NoFile *string `json:"noFile,omitempty"` +} + +// Validate validates this ulimit config +func (m *UlimitConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this ulimit config based on context it is used +func (m *UlimitConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UlimitConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UlimitConfig) UnmarshalBinary(b []byte) error { + var res UlimitConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/provisionclients/swagger/nodebootstrapping.json b/pkg/provisionclients/swagger/nodebootstrapping.json new file mode 100644 index 000000000..a9cb7ca87 --- /dev/null +++ b/pkg/provisionclients/swagger/nodebootstrapping.json @@ -0,0 +1,671 @@ +{ + "swagger": "2.0", + "info": { + "title": "NodeBootstrapping", + "description": "A swagger spec that defines the get NodeBootstrapping operation.", + "version": "2024-10-01" + }, + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping": { + "get": { + "operationId": "NodeBootstrapping_Get", + "summary": "Gets NodeBootstrapping values for a specified provisioning configuration, with secrets redacted.", + "description": "Gets NodeBootstrapping values for a specified provisioning configuration, with secrets redacted.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/ResourceNameParameter" + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProvisionValues" + }, + "description": "Values required to determine NodeBootstrapping values." + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/NodeBootstrapping" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "ProvisionValues": { + "type": "object", + "properties": { + "provisionProfile": { + "$ref": "#/definitions/ProvisionProfile", + "x-nullable": true + }, + "provisionHelperValues": { + "$ref": "#/definitions/ProvisionHelperValues", + "x-nullable": true + } + }, + "required": [ + "provisionProfile", + "provisionHelperValues" + ] + }, + "ProvisionProfile": { + "type": "object", + "properties": { + "name": { + "type": "string", + "x-nullable": true + }, + "vmSize": { + "type": "string", + "x-nullable": true + }, + "osType": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "osSku": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "storageProfile": { + "type": "string", + "x-nullable": true + }, + "distro": { + "type": "string", + "x-nullable": true + }, + "customNodeLabels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-nullable": true + }, + "orchestratorVersion": { + "type": "string", + "x-nullable": true + }, + "vnetCidrs": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "kubeletDiskType": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "vnetSubnetID": { + "type": "string", + "x-nullable": true + }, + "customKubeletConfig": { + "$ref": "#/definitions/CustomKubeletConfig", + "x-nullable": true + }, + "customLinuxOSConfig": { + "$ref": "#/definitions/CustomLinuxOSConfig", + "x-nullable": true + }, + "enableFIPS": { + "type": "boolean", + "x-nullable": true + }, + "mode": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "gpuInstanceProfile": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "workloadRuntime": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "messageOfTheDay": { + "type": "string", + "x-nullable": true + }, + "architecture": { + "type": "string", + "x-nullable": true + }, + "agentPoolWindowsProfile": { + "$ref": "#/definitions/AgentPoolWindowsProfile", + "x-nullable": true + }, + "securityProfile": { + "$ref": "#/definitions/AgentPoolSecurityProfile", + "x-nullable": true + }, + "gpuProfile": { + "$ref": "#/definitions/GPUProfile", + "x-nullable": true + }, + "artifactStreamingProfile": { + "$ref": "#/definitions/ArtifactStreamingProfile", + "x-nullable": true + }, + "nodeInitializationTaints": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "nodeTaints": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "maxPods": { + "type": "integer", + "format": "int32", + "x-nullable": true + } + }, + "required": [ + "name", + "vmSize", + "osType", + "osSku", + "storageProfile", + "distro", + "orchestratorVersion", + "vnetCidrs", + "vnetSubnetID", + "mode", + "architecture", + "maxPods" + ] + }, + "CustomKubeletConfig": { + "type": "object", + "properties": { + "cpuManagerPolicy": { + "type": "string", + "x-nullable": true + }, + "cpuCfsQuota": { + "type": "boolean", + "x-nullable": true + }, + "cpuCfsQuotaPeriod": { + "type": "string", + "x-nullable": true + }, + "imageGcHighThreshold": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "imageGcLowThreshold": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "topologyManagerPolicy": { + "type": "string", + "x-nullable": true + }, + "allowedUnsafeSysctls": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "failSwapOn": { + "type": "boolean", + "x-nullable": true + }, + "containerLogMaxSizeMB": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "containerLogMaxFiles": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "podMaxPids": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "cpuReserved": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "memoryReserved": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "seccompDefault": { + "type": "string", + "x-nullable": true + } + } + }, + "CustomLinuxOSConfig": { + "type": "object", + "properties": { + "sysctls": { + "$ref": "#/definitions/SysctlConfig", + "x-nullable": true + }, + "transparentHugePageEnabled": { + "type": "string", + "x-nullable": true + }, + "transparentHugePageDefrag": { + "type": "string", + "x-nullable": true + }, + "swapFileSizeMB": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "ulimits": { + "$ref": "#/definitions/UlimitConfig", + "x-nullable": true + } + } + }, + "SysctlConfig": { + "type": "object", + "properties": { + "netCoreSomaxconn": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreNetdevMaxBacklog": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreRmemDefault": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreRmemMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreWmemDefault": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreWmemMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netCoreOptmemMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpMaxSynBacklog": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpMaxTwBuckets": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpFinTimeout": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpKeepaliveTime": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpKeepaliveProbes": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpkeepaliveIntvl": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4TcpTwReuse": { + "type": "boolean", + "x-nullable": true + }, + "netIpv4IpLocalPortRange": { + "type": "string", + "x-nullable": true + }, + "netIpv4NeighDefaultGcThresh1": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4NeighDefaultGcThresh2": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netIpv4NeighDefaultGcThresh3": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netNetfilterNfConntrackMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "netNetfilterNfConntrackBuckets": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "fsInotifyMaxUserWatches": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "fsFileMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "fsAioMaxNr": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "fsNrOpen": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "kernelThreadsMax": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "vmMaxMapCount": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "vmSwappiness": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "vmVfsCachePressure": { + "type": "integer", + "format": "int32", + "x-nullable": true + } + } + }, + "UlimitConfig": { + "type": "object", + "properties": { + "noFile": { + "type": "string", + "x-nullable": true + }, + "maxLockedMemory": { + "type": "string", + "x-nullable": true + } + } + }, + "AgentPoolWindowsProfile": { + "type": "object", + "properties": { + "disableOutboundNat": { + "type": "boolean", + "x-nullable": true + }, + "containerdPackage": { + "type": "string", + "x-nullable": true + }, + "enableNextGenNetworking": { + "type": "boolean", + "x-nullable": true + } + } + }, + "AgentPoolSecurityProfile": { + "type": "object", + "properties": { + "sshAccess": { + "type": "integer", + "format": "int32", + "x-nullable": true + }, + "enableVTPM": { + "type": "boolean", + "x-nullable": true + }, + "enableSecureBoot": { + "type": "boolean", + "x-nullable": true + } + } + }, + "GPUProfile": { + "type": "object", + "properties": { + "installGPUDriver": { + "type": "boolean", + "x-nullable": true + }, + "driverType": { + "type": "integer", + "format": "int32", + "x-nullable": true + } + } + }, + "ArtifactStreamingProfile": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean", + "x-nullable": true + } + } + }, + "ProvisionHelperValues": { + "type": "object", + "properties": { + "skuCPU": { + "type": "number", + "format": "double", + "x-nullable": true + }, + "skuMemory": { + "type": "number", + "format": "double", + "x-nullable": true + } + }, + "required": [ + "skuCPU", + "skuMemory" + ] + }, + "SigImageConfigTemplate": { + "type": "object", + "properties": { + "resourceGroup": { + "type": "string", + "x-nullable": true + }, + "gallery": { + "type": "string", + "x-nullable": true + }, + "definition": { + "type": "string", + "x-nullable": true + }, + "version": { + "type": "string", + "x-nullable": true + } + } + }, + "SigImageConfig": { + "type": "object", + "properties": { + "sigImageConfigTemplate": { + "$ref": "#/definitions/SigImageConfigTemplate", + "x-nullable": true + }, + "subscriptionID": { + "type": "string", + "x-nullable": true + } + } + }, + "AzureOSImageConfig": { + "type": "object", + "properties": { + "imageOffer": { + "type": "string", + "x-nullable": true + }, + "imageSku": { + "type": "string", + "x-nullable": true + }, + "imagePublisher": { + "type": "string", + "x-nullable": true + }, + "imageVersion": { + "type": "string", + "x-nullable": true + } + } + }, + "NodeBootstrapping": { + "type": "object", + "properties": { + "customData": { + "type": "string", + "x-nullable": true + }, + "cse": { + "type": "string", + "x-nullable": true + }, + "osImageConfig": { + "$ref": "#/definitions/AzureOSImageConfig", + "x-nullable": true + }, + "sigImageConfig": { + "$ref": "#/definitions/SigImageConfig", + "x-nullable": true + } + }, + "required": [ + "customData", + "cse", + "osImageConfig", + "sigImageConfig" + ] + }, + "Error": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "code": { + "type": "integer", + "format": "int32" + }, + "subcode": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string" + }, + "ResourceGroupNameParameter": { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string" + }, + "ResourceNameParameter": { + "name": "resourceName", + "in": "path", + "required": true, + "type": "string" + } + } +} From 06d9613b507e88af636d61735390b0f5a27b2652 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Tue, 15 Oct 2024 20:19:54 -0700 Subject: [PATCH 02/16] feat: bootstrapping client provision mode --- go.mod | 24 +- go.sum | 54 ++-- pkg/operator/operator.go | 3 + pkg/operator/options/options.go | 10 +- pkg/operator/options/options_validation.go | 8 + .../agentbakerbootstrap.go | 29 +++ .../provisionclientbootstrap.go | 239 ++++++++++++++++++ pkg/providers/imagefamily/azlinux.go | 27 +- pkg/providers/imagefamily/image.go | 12 +- pkg/providers/imagefamily/resolver.go | 55 +++- pkg/providers/imagefamily/types.go | 1 + pkg/providers/imagefamily/ubuntu_2204.go | 27 +- pkg/providers/instance/instance.go | 97 ++++++- .../launchtemplate/launchtemplate.go | 57 +++-- .../launchtemplate/parameters/types.go | 9 +- pkg/utils/gpu.go | 6 +- 16 files changed, 595 insertions(+), 63 deletions(-) create mode 100644 pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go create mode 100644 pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go diff --git a/go.mod b/go.mod index 1e886c71f..661543154 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,11 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/go-logr/logr v1.4.2 github.com/go-logr/zapr v1.3.0 + github.com/go-openapi/errors v0.22.0 + github.com/go-openapi/runtime v0.28.0 + github.com/go-openapi/strfmt v0.23.0 + github.com/go-openapi/swag v0.23.0 + github.com/go-openapi/validate v0.24.0 github.com/go-playground/validator/v10 v10.22.1 github.com/imdario/mergo v0.3.16 github.com/jongio/azidext/go/azidext v0.5.0 @@ -65,6 +70,7 @@ require ( github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/avast/retry-go v3.0.0+incompatible // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blendle/zapdriver v1.3.1 // indirect @@ -79,9 +85,11 @@ require ( github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.20.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-openapi/analysis v0.23.0 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/loads v0.22.0 // indirect + github.com/go-openapi/spec v0.21.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect @@ -106,9 +114,12 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/oklog/ulid v1.3.1 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -120,11 +131,12 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + go.mongodb.org/mongo-driver v1.14.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect - go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/crypto v0.26.0 // indirect diff --git a/go.sum b/go.sum index 2c9ebabd9..5e7a47b35 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -140,7 +142,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -183,14 +184,26 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= -github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= -github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU= +github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo= +github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w= +github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= +github.com/go-openapi/loads v0.22.0 h1:ECPGd4jX1U6NApCGG1We+uEozOAvXvJSF4nnwHZ8Aco= +github.com/go-openapi/loads v0.22.0/go.mod h1:yLsaTCS92mnSAZX5WWoxszLj0u+Ojl+Zs5Stn1oF+rs= +github.com/go-openapi/runtime v0.28.0 h1:gpPPmWSNGo214l6n8hzdXYhPuJcGtziTOgUpvsFWGIQ= +github.com/go-openapi/runtime v0.28.0/go.mod h1:QN7OzcS+XuYmkQLw05akXk0jRH/eZ3kb18+1KwW9gyc= +github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= +github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= +github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c= +github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58= +github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -321,7 +334,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -337,6 +349,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -348,10 +362,14 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= @@ -436,6 +454,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= +go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -446,12 +466,14 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= -go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= -go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= -go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= -go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= -go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= -go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index c5d079073..d8a74cc3f 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -103,10 +103,12 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont options.FromContext(ctx).ClusterEndpoint, azConfig.TenantID, azConfig.SubscriptionID, + azConfig.ResourceGroup, azConfig.KubeletIdentityClientID, azConfig.NodeResourceGroup, azConfig.Location, vnetGUID, + options.FromContext(ctx).ProvisionMode, ) instanceTypeProvider := instancetype.NewProvider( azConfig.Location, @@ -129,6 +131,7 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont azConfig.Location, azConfig.NodeResourceGroup, azConfig.SubscriptionID, + options.FromContext(ctx).ProvisionMode, ) return ctx, &Operator{ diff --git a/pkg/operator/options/options.go b/pkg/operator/options/options.go index f8da8a3eb..aecb99f32 100644 --- a/pkg/operator/options/options.go +++ b/pkg/operator/options/options.go @@ -56,6 +56,10 @@ func (s *nodeIdentitiesValue) Get() any { return []string(*s) } func (s *nodeIdentitiesValue) String() string { return strings.Join(*s, ",") } +const ( + ProvisionModeBootstrappingClient = "bootstrappingclient" +) + type optionsKey struct{} type Options struct { @@ -74,7 +78,9 @@ type Options struct { SubnetID string // => VnetSubnetID to use (for nodes in Azure CNI Overlay and Azure CNI + pod subnet; for for nodes and pods in Azure CNI), unless overridden via AKSNodeClass setFlags map[string]bool - NodeResourceGroup string + NodeResourceGroup string + ProvisionMode string + NodeBootstrappingServerURL string } func (o *Options) AddFlags(fs *coreoptions.FlagSet) { @@ -90,6 +96,8 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) { fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR") fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.") fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live") + fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", ""), "[UNSUPPORTED] The provision mode for the cluster.") + fs.StringVar(&o.NodeBootstrappingServerURL, "nodebootstrapping-server-url", env.WithDefaultString("NODEBOOTSTRAPPING_SERVER_URL", ""), "[UNSUPPORTED] The url for the node bootstrapping provider server.") } func (o Options) GetAPIServerName() string { diff --git a/pkg/operator/options/options_validation.go b/pkg/operator/options/options_validation.go index ece1efff0..0acf7b304 100644 --- a/pkg/operator/options/options_validation.go +++ b/pkg/operator/options/options_validation.go @@ -34,6 +34,7 @@ func (o Options) Validate() error { o.validateNetworkingOptions(), o.validateVMMemoryOverheadPercent(), o.validateVnetSubnetID(), + o.validateProvisionMode(), validate.Struct(o), ) } @@ -83,6 +84,13 @@ func (o Options) validateVMMemoryOverheadPercent() error { return nil } +func (o Options) validateProvisionMode() error { + if o.ProvisionMode != "" && o.ProvisionMode != "bootstrappingclient" { + return fmt.Errorf("provision-mode is invalid: %s", o.ProvisionMode) + } + return nil +} + func (o Options) validateRequiredFields() error { if o.ClusterEndpoint == "" { return fmt.Errorf("missing field, cluster-endpoint") diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go new file mode 100644 index 000000000..3facfa21c --- /dev/null +++ b/pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go @@ -0,0 +1,29 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package agentbakerbootstrap + +import ( + "context" +) + +// Bootstrapper can be implemented to generate a bootstrap script +// that uses the params from the Bootstrap type for a specific +// bootstrapping method. +// The only one implemented right now is AKS bootstrap script +type Bootstrapper interface { + GetCustomDataAndCSE(ctx context.Context) (string, string, error) +} diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go new file mode 100644 index 000000000..522eed518 --- /dev/null +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -0,0 +1,239 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package agentbakerbootstrap + +import ( + "context" + "encoding/base64" + "fmt" + "strings" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" + "github.com/Azure/karpenter-provider-azure/pkg/operator/options" + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/client" + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/client/operations" + "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/models" + "github.com/Azure/karpenter-provider-azure/pkg/utils" + + core "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" + + corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" + "sigs.k8s.io/karpenter/pkg/cloudprovider" + + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/samber/lo" +) + +type ProvisionClientBootstrap struct { + ClusterName string + KubeletConfig *corev1beta1.KubeletConfiguration + Taints []core.Taint `hash:"set"` + StartupTaints []core.Taint `hash:"set"` + Labels map[string]string `hash:"set"` + SubnetID string + Arch string + SubscriptionID string + ClusterResourceGroup string + ResourceGroup string + KubeletClientTLSBootstrapToken string + KubernetesVersion string + ImageDistro string + IsWindows bool + InstanceType *cloudprovider.InstanceType + StorageProfile string + ImageFamily string +} + +var _ Bootstrapper = (*ProvisionClientBootstrap)(nil) // assert ProvisionClientBootstrap implements AgentBakerBootstrapper + +func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (string, string, error) { + if p.IsWindows { + // TODO(Windows) + return "", "", fmt.Errorf("windows is not supported") + } + + labels := lo.Assign(map[string]string{}, p.Labels) + getAgentbakerGeneratedLabels(p.ResourceGroup, labels) + + provisionProfile := &models.ProvisionProfile{ + Name: lo.ToPtr(""), + VMSize: lo.ToPtr(p.InstanceType.Name), + Distro: lo.ToPtr(p.ImageDistro), + CustomNodeLabels: labels, + OrchestratorVersion: lo.ToPtr(p.KubernetesVersion), + VnetSubnetID: lo.ToPtr(p.SubnetID), + StorageProfile: lo.ToPtr(p.StorageProfile), + NodeInitializationTaints: lo.Map(p.StartupTaints, func(taint v1.Taint, _ int) string { return taint.ToString() }), + NodeTaints: lo.Map(p.Taints, func(taint v1.Taint, _ int) string { return taint.ToString() }), + SecurityProfile: &models.AgentPoolSecurityProfile{ + SSHAccess: lo.ToPtr(models.SSHAccess_LocalUser), + // EnableVTPM: lo.ToPtr(false), // Unsupported as of now (Trusted launch) + // EnableSecureBoot: lo.ToPtr(false), // Unsupported as of now (Trusted launch) + }, + + // VnetCidrs: []string{}, // Unsupported as of now; TODO(Windows) + // MessageOfTheDay: lo.ToPtr(""), // Unsupported as of now + // AgentPoolWindowsProfile: &models.AgentPoolWindowsProfile{}, // Unsupported as of now; TODO(Windows) + // KubeletDiskType: lo.ToPtr(models.KubeletDiskType_Unspecified), // Unsupported as of now + // CustomLinuxOSConfig: &models.CustomLinuxOSConfig{}, // Unsupported as of now (sysctl) + // EnableFIPS: lo.ToPtr(false), // Unsupported as of now + // GpuInstanceProfile: lo.ToPtr(models.GPUInstanceProfile_Unspecified), // Unsupported as of now (MIG) + // WorkloadRuntime: lo.ToPtr(models.WorkloadRuntime_Unspecified), // Unsupported as of now (Kata) + // ArtifactStreamingProfile: &models.ArtifactStreamingProfile{ + // Enabled: lo.ToPtr(false), // Unsupported as of now + // }, + } + + if p.Arch == "amd64" { + provisionProfile.Architecture = lo.ToPtr("x64") + } else { + provisionProfile.Architecture = lo.ToPtr(p.Arch) + } + + switch p.ImageFamily { + case v1alpha2.Ubuntu2204ImageFamily: + provisionProfile.OsSku = to.Ptr(models.OSSKU_Ubuntu) + case v1alpha2.AzureLinuxImageFamily: + provisionProfile.OsSku = to.Ptr(models.OSSKU_AzureLinux) + default: + provisionProfile.OsSku = to.Ptr(models.OSSKU_Ubuntu) + } + + if p.KubeletConfig != nil { + provisionProfile.CustomKubeletConfig = &models.CustomKubeletConfig{ + // AllowedUnsafeSysctls: ..., // Unsupported as of now + CPUCfsQuota: p.KubeletConfig.CPUCFSQuota, + } + } + + if p.KubeletConfig != nil && p.KubeletConfig.MaxPods != nil { + provisionProfile.MaxPods = p.KubeletConfig.MaxPods + } else { + provisionProfile.MaxPods = lo.ToPtr(int32(250)) // Delegatable defaulting? + } + + if modeString, ok := p.Labels["kubernetes.azure.com/mode"]; ok && modeString == "system" { + provisionProfile.Mode = lo.ToPtr(models.AgentPoolMode_System) + } else { + provisionProfile.Mode = lo.ToPtr(models.AgentPoolMode_User) + } + + if utils.IsNvidiaEnabledSKU(p.InstanceType.Name) { + if utils.UseGridDrivers(p.InstanceType.Name) { + provisionProfile.GpuProfile = &models.GPUProfile{ + DriverType: lo.ToPtr(models.DriverType_GRID), + InstallGPUDriver: lo.ToPtr(true), + } + } else { + provisionProfile.GpuProfile = &models.GPUProfile{ + DriverType: lo.ToPtr(models.DriverType_CUDA), + InstallGPUDriver: lo.ToPtr(true), + } + } + + } + + if p.IsWindows { + provisionProfile.OsType = lo.ToPtr(models.OSType_Windows) + } else { + provisionProfile.OsType = lo.ToPtr(models.OSType_Linux) + } + + provisionHelperValues := &models.ProvisionHelperValues{ + SkuCPU: lo.ToPtr(p.InstanceType.Capacity.Cpu().AsApproximateFloat64()), + SkuMemory: lo.ToPtr(p.InstanceType.Capacity.Memory().AsApproximateFloat64()), + } + + return p.getNodeBootstrappingFromClient(ctx, provisionProfile, provisionHelperValues, p.KubeletClientTLSBootstrapToken) +} + +func (p *ProvisionClientBootstrap) getNodeBootstrappingFromClient(ctx context.Context, provisionProfile *models.ProvisionProfile, provisionHelperValues *models.ProvisionHelperValues, bootstrapToken string) (string, string, error) { + transport := httptransport.New(options.FromContext(ctx).NodeBootstrappingServerURL, "/", []string{"http"}) + client := client.New(transport, strfmt.Default) + + params := operations.NewNodeBootstrappingGetParams() + params.ResourceGroupName = p.ClusterResourceGroup + params.ResourceName = p.ClusterName + params.SubscriptionID = p.SubscriptionID + provisionValues := &models.ProvisionValues{ + ProvisionProfile: provisionProfile, + ProvisionHelperValues: provisionHelperValues, + } + params.Parameters = provisionValues + + params.WithTimeout(30 * time.Second) + params.Context = ctx + + resp, err := client.Operations.NodeBootstrappingGet(params) + if err != nil { + return "", "", err + } + + if resp.Payload == nil { + return "", "", fmt.Errorf("no payload in response") + } + if resp.Payload.Cse == nil || *resp.Payload.Cse == "" { + return "", "", fmt.Errorf("no CSE in response") + } + if resp.Payload.CustomData == nil || *resp.Payload.CustomData == "" { + return "", "", fmt.Errorf("no CustomData in response") + } + + cseWithoutBootstrapToken := *resp.Payload.Cse + customDataWithoutBootstrapToken := *resp.Payload.CustomData + + cseWithBootstrapToken := strings.ReplaceAll(cseWithoutBootstrapToken, "{{.TokenID}}.{{.TokenSecret}}", bootstrapToken) + + decodedCustomDataWithoutBootstrapTokenInBytes, err := base64.StdEncoding.DecodeString(customDataWithoutBootstrapToken) + if err != nil { + return "", "", err + } + decodedCustomDataWithBootstrapToken := strings.ReplaceAll(string(decodedCustomDataWithoutBootstrapTokenInBytes), "{{.TokenID}}.{{.TokenSecret}}", bootstrapToken) + customDataWithBootstrapToken := base64.StdEncoding.EncodeToString([]byte(decodedCustomDataWithBootstrapToken)) + + return customDataWithBootstrapToken, cseWithBootstrapToken, nil +} + +func getAgentbakerGeneratedLabels(nodeResourceGroup string, nodeLabels map[string]string) { + // Delegatable defaulting? + nodeLabels["kubernetes.azure.com/role"] = "agent" + nodeLabels["kubernetes.azure.com/cluster"] = normalizeResourceGroupNameForLabel(nodeResourceGroup) +} + +func normalizeResourceGroupNameForLabel(resourceGroupName string) string { + truncated := resourceGroupName + truncated = strings.ReplaceAll(truncated, "(", "-") + truncated = strings.ReplaceAll(truncated, ")", "-") + const maxLen = 63 + if len(truncated) > maxLen { + truncated = truncated[0:maxLen] + } + + if strings.HasSuffix(truncated, "-") || + strings.HasSuffix(truncated, "_") || + strings.HasSuffix(truncated, ".") { + if len(truncated) > 62 { + return truncated[0:len(truncated)-1] + "z" + } + return truncated + "z" + } + return truncated +} diff --git a/pkg/providers/imagefamily/azlinux.go b/pkg/providers/imagefamily/azlinux.go index f4f4beff4..7c2b7b3ba 100644 --- a/pkg/providers/imagefamily/azlinux.go +++ b/pkg/providers/imagefamily/azlinux.go @@ -20,6 +20,7 @@ import ( v1 "k8s.io/api/core/v1" "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" @@ -52,6 +53,7 @@ func (u AzureLinux) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureAmd64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV2), ), + Distro: "aks-azurelinux-v2-gen2", }, { CommunityImage: AzureLinuxGen1CommunityImage, @@ -60,6 +62,7 @@ func (u AzureLinux) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureAmd64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV1), ), + Distro: "aks-azurelinux-v2", }, { CommunityImage: AzureLinuxGen2ArmCommunityImage, @@ -68,12 +71,13 @@ func (u AzureLinux) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureArm64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV2), ), + Distro: "aks-azurelinux-v2-arm64-gen2", }, } } // UserData returns the default userdata script for the image Family -func (u AzureLinux) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u AzureLinux) SelfContainedUserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, @@ -102,3 +106,24 @@ func (u AzureLinux) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, ta KubernetesVersion: u.Options.KubernetesVersion, } } + +// UserData returns the default userdata script for the image Family +func (u AzureLinux) AgentBakerNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) agentbakerbootstrap.Bootstrapper { + return agentbakerbootstrap.ProvisionClientBootstrap{ + ClusterName: u.Options.ClusterName, + KubeletConfig: kubeletConfig, + Taints: taints, + StartupTaints: startupTaints, + Labels: labels, + SubnetID: u.Options.SubnetID, + Arch: u.Options.Arch, + SubscriptionID: u.Options.SubscriptionID, + ResourceGroup: u.Options.ResourceGroup, + KubeletClientTLSBootstrapToken: u.Options.KubeletClientTLSBootstrapToken, + KubernetesVersion: u.Options.KubernetesVersion, + ImageDistro: imageDistro, + InstanceType: instanceType, + StorageProfile: storageProfile, + ClusterResourceGroup: u.Options.ClusterResourceGroup, + } +} diff --git a/pkg/providers/imagefamily/image.go b/pkg/providers/imagefamily/image.go index 24ea41f41..d42660abb 100644 --- a/pkg/providers/imagefamily/image.go +++ b/pkg/providers/imagefamily/image.go @@ -62,17 +62,21 @@ func NewProvider(kubernetesInterface kubernetes.Interface, kubernetesVersionCach } } -// Get returns Image ID for the given instance type. Images may vary due to architecture, accelerator, etc -func (p *Provider) Get(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, instanceType *cloudprovider.InstanceType, imageFamily ImageFamily) (string, error) { +// Get returns Distro and Image ID for the given instance type. Images may vary due to architecture, accelerator, etc +func (p *Provider) Get(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, instanceType *cloudprovider.InstanceType, imageFamily ImageFamily) (string, string, error) { defaultImages := imageFamily.DefaultImages() for _, defaultImage := range defaultImages { if err := instanceType.Requirements.Compatible(defaultImage.Requirements, v1alpha2.AllowUndefinedLabels); err == nil { communityImageName, publicGalleryURL := defaultImage.CommunityImage, defaultImage.PublicGalleryURL - return p.GetImageID(ctx, communityImageName, publicGalleryURL) + imageID, err := p.GetImageID(ctx, communityImageName, publicGalleryURL) + if err != nil { + return "", "", err + } + return defaultImage.Distro, imageID, nil } } - return "", fmt.Errorf("no compatible images found for instance type %s", instanceType.Name) + return "", "", fmt.Errorf("no compatible images found for instance type %s", instanceType.Name) } func (p *Provider) KubeServerVersion(ctx context.Context) (string, error) { diff --git a/pkg/providers/imagefamily/resolver.go b/pkg/providers/imagefamily/resolver.go index 40e62fa5d..b35b5719d 100644 --- a/pkg/providers/imagefamily/resolver.go +++ b/pkg/providers/imagefamily/resolver.go @@ -18,6 +18,7 @@ package imagefamily import ( "context" + "strconv" core "k8s.io/api/core/v1" "knative.dev/pkg/logging" @@ -26,12 +27,14 @@ import ( "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" "github.com/Azure/karpenter-provider-azure/pkg/consts" "github.com/Azure/karpenter-provider-azure/pkg/metrics" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/instancetype" template "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" "github.com/samber/lo" corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" "sigs.k8s.io/karpenter/pkg/cloudprovider" + corecloudprovider "sigs.k8s.io/karpenter/pkg/cloudprovider" "sigs.k8s.io/karpenter/pkg/utils/resources" ) @@ -42,13 +45,22 @@ type Resolver struct { // ImageFamily can be implemented to override the default logic for generating dynamic launch template parameters type ImageFamily interface { - UserData( + SelfContainedUserData( kubeletConfig *corev1beta1.KubeletConfiguration, taints []core.Taint, labels map[string]string, caBundle *string, instanceType *cloudprovider.InstanceType, ) bootstrap.Bootstrapper + AgentBakerNodeBootstrapping( + kubeletConfig *corev1beta1.KubeletConfiguration, + taints []core.Taint, + startupTaints []core.Taint, + labels map[string]string, + instanceType *cloudprovider.InstanceType, + imageDistro string, + storageProfile string, + ) agentbakerbootstrap.Bootstrapper Name() string // DefaultImages returns a list of default CommunityImage definitions for this ImageFamily. // Our Image Selection logic relies on the ordering of the default images to be ordered from most preferred to least, then we will select the latest image version available for that CommunityImage definition. @@ -67,7 +79,7 @@ func New(_ client.Client, imageProvider *Provider) *Resolver { func (r Resolver) Resolve(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, nodeClaim *corev1beta1.NodeClaim, instanceType *cloudprovider.InstanceType, staticParameters *template.StaticParameters) (*template.Parameters, error) { imageFamily := getImageFamily(nodeClass.Spec.ImageFamily, staticParameters) - imageID, err := r.imageProvider.Get(ctx, nodeClass, instanceType, imageFamily) + imageDistro, imageID, err := r.imageProvider.Get(ctx, nodeClass, instanceType, imageFamily) if err != nil { metrics.ImageSelectionErrorCount.WithLabelValues(imageFamily.Name()).Inc() return nil, err @@ -75,16 +87,32 @@ func (r Resolver) Resolve(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, logging.FromContext(ctx).Infof("Resolved image %s for instance type %s", imageID, instanceType.Name) + storageProfile := "ManagedDisks" + if useEphemeralDisk(instanceType, nodeClass) { + storageProfile = "Ephemeral" + } + template := &template.Parameters{ StaticParameters: staticParameters, - UserData: imageFamily.UserData( + SelfContainedUserData: imageFamily.SelfContainedUserData( prepareKubeletConfiguration(instanceType, nodeClaim), append(nodeClaim.Spec.Taints, nodeClaim.Spec.StartupTaints...), staticParameters.Labels, staticParameters.CABundle, instanceType, ), - ImageID: imageID, + AgentBakerNodeBootstrapping: imageFamily.AgentBakerNodeBootstrapping( + prepareKubeletConfiguration(instanceType, nodeClaim), + nodeClaim.Spec.Taints, + nodeClaim.Spec.StartupTaints, + staticParameters.Labels, + instanceType, + imageDistro, + storageProfile, + ), + ImageID: imageID, + StorageProfile: storageProfile, + IsWindows: false, // TODO(Windows) } return template, nil @@ -113,3 +141,22 @@ func getImageFamily(familyName *string, parameters *template.StaticParameters) I return &Ubuntu2204{Options: parameters} } } + +func getEphemeralMaxSizeGB(instanceType *corecloudprovider.InstanceType) int32 { + reqs := instanceType.Requirements.Get(v1alpha2.LabelSKUStorageEphemeralOSMaxSize).Values() + if len(reqs) == 0 || len(reqs) > 1 { + return 0 + } + maxSize, err := strconv.ParseFloat(reqs[0], 32) + if err != nil { + return 0 + } + // decimal places are truncated, so we round down + return int32(maxSize) +} + +// setVMPropertiesStorageProfile enables ephemeral os disk for instance types that support it +func useEphemeralDisk(instanceType *corecloudprovider.InstanceType, nodeClass *v1alpha2.AKSNodeClass) bool { + // use ephemeral disk if it is large enough + return *nodeClass.Spec.OSDiskSizeGB <= getEphemeralMaxSizeGB(instanceType) +} diff --git a/pkg/providers/imagefamily/types.go b/pkg/providers/imagefamily/types.go index 9268fa2c8..b3c3510aa 100644 --- a/pkg/providers/imagefamily/types.go +++ b/pkg/providers/imagefamily/types.go @@ -32,6 +32,7 @@ type DefaultImageOutput struct { CommunityImage string PublicGalleryURL string Requirements scheduling.Requirements + Distro string } // CommunityGalleryImageVersionsAPI is used for listing community gallery image versions. diff --git a/pkg/providers/imagefamily/ubuntu_2204.go b/pkg/providers/imagefamily/ubuntu_2204.go index 4542fbef7..84653d115 100644 --- a/pkg/providers/imagefamily/ubuntu_2204.go +++ b/pkg/providers/imagefamily/ubuntu_2204.go @@ -20,6 +20,7 @@ import ( v1 "k8s.io/api/core/v1" "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" @@ -52,6 +53,7 @@ func (u Ubuntu2204) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureAmd64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV2), ), + Distro: "aks-ubuntu-containerd-22.04-gen2", }, { CommunityImage: Ubuntu2204Gen1CommunityImage, @@ -60,6 +62,7 @@ func (u Ubuntu2204) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureAmd64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV1), ), + Distro: "aks-ubuntu-containerd-22.04", }, { CommunityImage: Ubuntu2204Gen2ArmCommunityImage, @@ -68,12 +71,13 @@ func (u Ubuntu2204) DefaultImages() []DefaultImageOutput { scheduling.NewRequirement(v1.LabelArchStable, v1.NodeSelectorOpIn, corev1beta1.ArchitectureArm64), scheduling.NewRequirement(v1alpha2.LabelSKUHyperVGeneration, v1.NodeSelectorOpIn, v1alpha2.HyperVGenerationV2), ), + Distro: "aks-ubuntu-arm64-containerd-22.04-gen2", }, } } // UserData returns the default userdata script for the image Family -func (u Ubuntu2204) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u Ubuntu2204) SelfContainedUserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, @@ -101,3 +105,24 @@ func (u Ubuntu2204) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, ta KubernetesVersion: u.Options.KubernetesVersion, } } + +// UserData returns the default userdata script for the image Family +func (u Ubuntu2204) AgentBakerNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) agentbakerbootstrap.Bootstrapper { + return agentbakerbootstrap.ProvisionClientBootstrap{ + ClusterName: u.Options.ClusterName, + KubeletConfig: kubeletConfig, + Taints: taints, + StartupTaints: startupTaints, + Labels: labels, + SubnetID: u.Options.SubnetID, + Arch: u.Options.Arch, + SubscriptionID: u.Options.SubscriptionID, + ResourceGroup: u.Options.ResourceGroup, + KubeletClientTLSBootstrapToken: u.Options.KubeletClientTLSBootstrapToken, + KubernetesVersion: u.Options.KubernetesVersion, + ImageDistro: imageDistro, + InstanceType: instanceType, + StorageProfile: storageProfile, + ClusterResourceGroup: u.Options.ClusterResourceGroup, + } +} diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index a114df114..a19caf0f5 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -88,6 +88,7 @@ type Provider struct { resourceGroup string subscriptionID string unavailableOfferings *cache.UnavailableOfferings + provisionMode string } func NewProvider( @@ -99,6 +100,7 @@ func NewProvider( location string, resourceGroup string, subscriptionID string, + provisionMode string, ) *Provider { listQuery = GetListQueryBuilder(resourceGroup).String() return &Provider{ @@ -110,6 +112,7 @@ func NewProvider( resourceGroup: resourceGroup, subscriptionID: subscriptionID, unavailableOfferings: offeringsCache, + provisionMode: provisionMode, } } @@ -119,6 +122,7 @@ func (p *Provider) Create(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, instanceTypes = orderInstanceTypesByPrice(instanceTypes, scheduling.NewNodeSelectorRequirementsWithMinValues(nodeClaim.Spec.Requirements...)) vm, instanceType, err := p.launchInstance(ctx, nodeClass, nodeClaim, instanceTypes) if err != nil { + // Currently, CSE errors will lead to here if cleanupErr := p.cleanupAzureResources(ctx, GenerateResourceName(nodeClaim.Name)); cleanupErr != nil { logging.FromContext(ctx).Errorf("failed to cleanup resources for node claim %s, %w", nodeClaim.Name, cleanupErr) } @@ -193,6 +197,19 @@ func (p *Provider) createAKSIdentifyingExtension(ctx context.Context, vmName str return nil } +func (p *Provider) createCSExtension(ctx context.Context, vmName string, cse string, isWindows bool) (err error) { + vmExt := p.getCSExtension(cse, isWindows) + vmExtName := *vmExt.Name + logging.FromContext(ctx).Debugf("Creating virtual machine CSE for %s", vmName) + v, err := createVirtualMachineExtension(ctx, p.AZClient.virtualMachinesExtensionClient, p.resourceGroup, vmName, vmExtName, *vmExt) + if err != nil { + logging.FromContext(ctx).Errorf("Creating VM CSE for VM %q failed, %w", vmName, err) + return fmt.Errorf("creating VM CSE for VM %q, %w failed", vmName, err) + } + logging.FromContext(ctx).Debugf("Created virtual machine CSE for %s, with an id of %s", vmName, *v.ID) + return nil +} + func (p *Provider) newNetworkInterfaceForVM(opts *createNICOptions) armnetwork.Interface { var ipv4BackendPools []*armnetwork.BackendAddressPool for _, poolID := range opts.BackendPools.IPv4PoolIDs { @@ -284,11 +301,17 @@ func newVMObject( nodeIdentities []string, nodeClass *v1alpha2.AKSNodeClass, launchTemplate *launchtemplate.Template, - instanceType *corecloudprovider.InstanceType) armcompute.VirtualMachine { + instanceType *corecloudprovider.InstanceType, + provisionMode string) armcompute.VirtualMachine { // Build the image reference from template imageReference := armcompute.ImageReference{ CommunityGalleryImageID: &launchTemplate.ImageID, } + + if launchTemplate.IsWindows { + return armcompute.VirtualMachine{} // TODO(Windows) + } + vm := armcompute.VirtualMachine{ Location: lo.ToPtr(location), Identity: ConvertToVirtualMachineIdentity(nodeIdentities), @@ -333,7 +356,6 @@ func newVMObject( }, }, }, - CustomData: lo.ToPtr(launchTemplate.UserData), }, Priority: lo.ToPtr(armcompute.VirtualMachinePriorityTypes( CapacityTypeToPriority[capacityType]), @@ -342,16 +364,21 @@ func newVMObject( Zones: lo.Ternary(len(zone) > 0, []*string{&zone}, []*string{}), Tags: launchTemplate.Tags, } - setVMPropertiesStorageProfile(vm.Properties, instanceType, nodeClass) + setVMPropertiesStorageProfile(vm.Properties, launchTemplate.StorageProfile) setVMPropertiesBillingProfile(vm.Properties, capacityType) + if provisionMode == options.ProvisionModeBootstrappingClient { + vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.AgentBakerCustomData) + } else { + vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.SelfContainedUserData) + } + return vm } // setVMPropertiesStorageProfile enables ephemeral os disk for instance types that support it -func setVMPropertiesStorageProfile(vmProperties *armcompute.VirtualMachineProperties, instanceType *corecloudprovider.InstanceType, nodeClass *v1alpha2.AKSNodeClass) { - // use ephemeral disk if it is large enough - if *nodeClass.Spec.OSDiskSizeGB <= getEphemeralMaxSizeGB(instanceType) { +func setVMPropertiesStorageProfile(vmProperties *armcompute.VirtualMachineProperties, storageProfile string) { + if storageProfile == "Ephemeral" { vmProperties.StorageProfile.OSDisk.DiffDiskSettings = &armcompute.DiffDiskSettings{ Option: lo.ToPtr(armcompute.DiffDiskOptionsLocal), // placement (cache/resource) is left to CRP @@ -425,7 +452,7 @@ func (p *Provider) launchInstance( sshPublicKey := options.FromContext(ctx).SSHPublicKey nodeIdentityIDs := options.FromContext(ctx).NodeIdentities - vm := newVMObject(resourceName, nicReference, zone, capacityType, p.location, sshPublicKey, nodeIdentityIDs, nodeClass, launchTemplate, instanceType) + vm := newVMObject(resourceName, nicReference, zone, capacityType, p.location, sshPublicKey, nodeIdentityIDs, nodeClass, launchTemplate, instanceType, p.provisionMode) logging.FromContext(ctx).Debugf("Creating virtual machine %s (%s)", resourceName, instanceType.Name) // Uses AZ Client to create a new virtual machine using the vm object we prepared earlier @@ -435,6 +462,14 @@ func (p *Provider) launchInstance( return nil, nil, azErr } + if p.provisionMode == options.ProvisionModeBootstrappingClient { + err = p.createCSExtension(ctx, resourceName, launchTemplate.AgentBakerCSE, launchTemplate.IsWindows) + if err != nil { + // This should fall back to cleanupAzureResources + return nil, nil, err + } + } + err = p.createAKSIdentifyingExtension(ctx, resourceName) if err != nil { return nil, nil, err @@ -670,6 +705,54 @@ func (p *Provider) getAKSIdentifyingExtension() *armcompute.VirtualMachineExtens return vmExtension } +func (p *Provider) getCSExtension(cse string, isWindows bool) *armcompute.VirtualMachineExtension { + const ( + vmExtensionType = "Microsoft.Compute/virtualMachines/extensions" + cseNameWindows = "windows-cse-agent-karpenter" + cseTypeWindows = "CustomScriptExtension" + csePublisherWindows = "Microsoft.Compute" + cseVersionWindows = "1.10" + cseNameLinux = "cse-agent-karpenter" + cseTypeLinux = "CustomScript" + csePublisherLinux = "Microsoft.Azure.Extensions" + cseVersionLinux = "2.0" + ) + + if isWindows { // TODO(Windows) + return &armcompute.VirtualMachineExtension{ + Location: lo.ToPtr(p.location), + Name: lo.ToPtr(cseNameWindows), + Type: lo.ToPtr(vmExtensionType), + Properties: &armcompute.VirtualMachineExtensionProperties{ + AutoUpgradeMinorVersion: lo.ToPtr(true), + Type: lo.ToPtr(cseTypeWindows), + Publisher: lo.ToPtr(csePublisherWindows), + TypeHandlerVersion: lo.ToPtr(cseVersionWindows), + Settings: &map[string]interface{}{}, + ProtectedSettings: &map[string]interface{}{ + "commandToExecute": cse, + }, + }, + } + } else { + return &armcompute.VirtualMachineExtension{ + Location: lo.ToPtr(p.location), + Name: lo.ToPtr(cseNameLinux), + Type: lo.ToPtr(vmExtensionType), + Properties: &armcompute.VirtualMachineExtensionProperties{ + AutoUpgradeMinorVersion: lo.ToPtr(true), + Type: lo.ToPtr(cseTypeLinux), + Publisher: lo.ToPtr(csePublisherLinux), + TypeHandlerVersion: lo.ToPtr(cseVersionLinux), + Settings: &map[string]interface{}{}, + ProtectedSettings: &map[string]interface{}{ + "commandToExecute": cse, + }, + }, + } + } +} + // GetZoneID returns the zone ID for the given virtual machine, or an empty string if there is no zone specified func GetZoneID(vm *armcompute.VirtualMachine) (string, error) { if vm == nil { diff --git a/pkg/providers/launchtemplate/launchtemplate.go b/pkg/providers/launchtemplate/launchtemplate.go index 6cc180a29..3aaf73ba0 100644 --- a/pkg/providers/launchtemplate/launchtemplate.go +++ b/pkg/providers/launchtemplate/launchtemplate.go @@ -45,10 +45,14 @@ const ( ) type Template struct { - UserData string - ImageID string - SubnetID string - Tags map[string]*string + SelfContainedUserData string + ImageID string + SubnetID string + Tags map[string]*string + AgentBakerCustomData string + AgentBakerCSE string + IsWindows bool + StorageProfile string } type Provider struct { @@ -60,14 +64,16 @@ type Provider struct { subscriptionID string kubeletIdentityClientID string resourceGroup string + clusterResourceGroup string location string vnetGUID string + provisionMode string } // TODO: add caching of launch templates func NewProvider(_ context.Context, imageFamily *imagefamily.Resolver, imageProvider *imagefamily.Provider, caBundle *string, clusterEndpoint string, - tenantID, subscriptionID, kubeletIdentityClientID, resourceGroup, location, vnetGUID string, + tenantID, subscriptionID, clusterResourceGroup string, kubeletIdentityClientID, resourceGroup, location, vnetGUID, provisionMode string, ) *Provider { return &Provider{ imageFamily: imageFamily, @@ -78,8 +84,10 @@ func NewProvider(_ context.Context, imageFamily *imagefamily.Resolver, imageProv subscriptionID: subscriptionID, kubeletIdentityClientID: kubeletIdentityClientID, resourceGroup: resourceGroup, + clusterResourceGroup: clusterResourceGroup, location: location, vnetGUID: vnetGUID, + provisionMode: provisionMode, } } @@ -99,7 +107,7 @@ func (p *Provider) GetTemplate(ctx context.Context, nodeClass *v1alpha2.AKSNodeC if err != nil { return nil, err } - launchTemplate, err := p.createLaunchTemplate(templateParameters) + launchTemplate, err := p.createLaunchTemplate(ctx, templateParameters) if err != nil { return nil, err } @@ -156,24 +164,37 @@ func (p *Provider) getStaticParameters(ctx context.Context, instanceType *cloudp NetworkPlugin: options.FromContext(ctx).NetworkPlugin, NetworkPolicy: options.FromContext(ctx).NetworkPolicy, SubnetID: subnetID, + ClusterResourceGroup: p.clusterResourceGroup, }, nil } -func (p *Provider) createLaunchTemplate(options *parameters.Parameters) (*Template, error) { - // render user data - userData, err := options.UserData.Script() - if err != nil { - return nil, err - } - +func (p *Provider) createLaunchTemplate(ctx context.Context, params *parameters.Parameters) (*Template, error) { // merge and convert to ARM tags - azureTags := mergeTags(options.Tags, map[string]string{karpenterManagedTagKey: options.ClusterName}) + azureTags := mergeTags(params.Tags, map[string]string{karpenterManagedTagKey: params.ClusterName}) template := &Template{ - UserData: userData, - ImageID: options.ImageID, - Tags: azureTags, - SubnetID: options.SubnetID, + ImageID: params.ImageID, + Tags: azureTags, + SubnetID: params.SubnetID, + IsWindows: params.IsWindows, + StorageProfile: params.StorageProfile, } + + if p.provisionMode == options.ProvisionModeBootstrappingClient { + customData, cse, err := params.AgentBakerNodeBootstrapping.GetCustomDataAndCSE(ctx) + if err != nil { + return nil, err + } + template.AgentBakerCustomData = customData + template.AgentBakerCSE = cse + } else { + // render user data + userData, err := params.SelfContainedUserData.Script() + if err != nil { + return nil, err + } + template.SelfContainedUserData = userData + } + return template, nil } diff --git a/pkg/providers/launchtemplate/parameters/types.go b/pkg/providers/launchtemplate/parameters/types.go index 9ccbd8cb3..4d0b96694 100644 --- a/pkg/providers/launchtemplate/parameters/types.go +++ b/pkg/providers/launchtemplate/parameters/types.go @@ -17,6 +17,7 @@ limitations under the License. package parameters import ( + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" ) @@ -41,6 +42,7 @@ type StaticParameters struct { NetworkPolicy string KubernetesVersion string SubnetID string + ClusterResourceGroup string Tags map[string]string Labels map[string]string @@ -49,6 +51,9 @@ type StaticParameters struct { // Parameters adds the dynamically generated launch template parameters type Parameters struct { *StaticParameters - UserData bootstrap.Bootstrapper - ImageID string + SelfContainedUserData bootstrap.Bootstrapper + AgentBakerNodeBootstrapping agentbakerbootstrap.Bootstrapper + ImageID string + StorageProfile string + IsWindows bool } diff --git a/pkg/utils/gpu.go b/pkg/utils/gpu.go index f9a7dc416..75dc5bcc7 100644 --- a/pkg/utils/gpu.go +++ b/pkg/utils/gpu.go @@ -33,7 +33,7 @@ const ( ) func GetAKSGPUImageSHA(size string) string { - if useGridDrivers(size) { + if UseGridDrivers(size) { return AKSGPUGridSHA } return AKSGPUCudaSHA @@ -142,7 +142,7 @@ func IsMarinerEnabledGPUSKU(vmSize string) bool { // NVv1 seems to run with CUDA, NVv5 requires GRID. // NVv3 is untested on AKS, NVv4 is AMD so n/a, and NVv2 no longer seems to exist (?). func GetGPUDriverVersion(size string) string { - if useGridDrivers(size) { + if UseGridDrivers(size) { return Nvidia535GridDriverVersion } if isStandardNCv1(size) { @@ -156,7 +156,7 @@ func isStandardNCv1(size string) bool { return strings.HasPrefix(tmp, "standard_nc") && !strings.Contains(tmp, "_v") } -func useGridDrivers(size string) bool { +func UseGridDrivers(size string) bool { return ConvergedGPUDriverSizes[strings.ToLower(size)] } From d8ff98231518d2fb04a1be3cd22e113a8d71af3c Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:36:40 -0700 Subject: [PATCH 03/16] chore: general code improvements --- .../provisionclientbootstrap.go | 29 +++-------- pkg/providers/imagefamily/azlinux.go | 2 +- pkg/providers/imagefamily/resolver.go | 4 +- pkg/providers/imagefamily/ubuntu_2204.go | 2 +- pkg/providers/instance/instance.go | 52 ++++++------------- .../launchtemplate/launchtemplate.go | 20 +++---- .../launchtemplate/parameters/types.go | 2 +- 7 files changed, 38 insertions(+), 73 deletions(-) diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index 522eed518..f93bcd504 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -75,6 +75,8 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri provisionProfile := &models.ProvisionProfile{ Name: lo.ToPtr(""), + Architecture: lo.ToPtr(lo.Ternary(p.Arch == corev1beta1.ArchitectureAmd64, "x64", "Arm64")), + OsType: lo.ToPtr(lo.Ternary(p.IsWindows, models.OSType_Windows, models.OSType_Linux)), VMSize: lo.ToPtr(p.InstanceType.Name), Distro: lo.ToPtr(p.ImageDistro), CustomNodeLabels: labels, @@ -102,12 +104,6 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri // }, } - if p.Arch == "amd64" { - provisionProfile.Architecture = lo.ToPtr("x64") - } else { - provisionProfile.Architecture = lo.ToPtr(p.Arch) - } - switch p.ImageFamily { case v1alpha2.Ubuntu2204ImageFamily: provisionProfile.OsSku = to.Ptr(models.OSSKU_Ubuntu) @@ -137,24 +133,10 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri } if utils.IsNvidiaEnabledSKU(p.InstanceType.Name) { - if utils.UseGridDrivers(p.InstanceType.Name) { - provisionProfile.GpuProfile = &models.GPUProfile{ - DriverType: lo.ToPtr(models.DriverType_GRID), - InstallGPUDriver: lo.ToPtr(true), - } - } else { - provisionProfile.GpuProfile = &models.GPUProfile{ - DriverType: lo.ToPtr(models.DriverType_CUDA), - InstallGPUDriver: lo.ToPtr(true), - } + provisionProfile.GpuProfile = &models.GPUProfile{ + DriverType: lo.ToPtr(lo.Ternary(utils.UseGridDrivers(p.InstanceType.Name), models.DriverType_GRID, models.DriverType_CUDA)), + InstallGPUDriver: lo.ToPtr(true), } - - } - - if p.IsWindows { - provisionProfile.OsType = lo.ToPtr(models.OSType_Windows) - } else { - provisionProfile.OsType = lo.ToPtr(models.OSType_Linux) } provisionHelperValues := &models.ProvisionHelperValues{ @@ -184,6 +166,7 @@ func (p *ProvisionClientBootstrap) getNodeBootstrappingFromClient(ctx context.Co resp, err := client.Operations.NodeBootstrappingGet(params) if err != nil { + // As of now we just fail the provisioning given the unlikely scenario of retriable error, but could be revisted along with retriable status on the server side. return "", "", err } diff --git a/pkg/providers/imagefamily/azlinux.go b/pkg/providers/imagefamily/azlinux.go index 7c2b7b3ba..b213819f2 100644 --- a/pkg/providers/imagefamily/azlinux.go +++ b/pkg/providers/imagefamily/azlinux.go @@ -77,7 +77,7 @@ func (u AzureLinux) DefaultImages() []DefaultImageOutput { } // UserData returns the default userdata script for the image Family -func (u AzureLinux) SelfContainedUserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u AzureLinux) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, diff --git a/pkg/providers/imagefamily/resolver.go b/pkg/providers/imagefamily/resolver.go index b35b5719d..6b416bb96 100644 --- a/pkg/providers/imagefamily/resolver.go +++ b/pkg/providers/imagefamily/resolver.go @@ -45,7 +45,7 @@ type Resolver struct { // ImageFamily can be implemented to override the default logic for generating dynamic launch template parameters type ImageFamily interface { - SelfContainedUserData( + SelfContainedCustomData( kubeletConfig *corev1beta1.KubeletConfiguration, taints []core.Taint, labels map[string]string, @@ -94,7 +94,7 @@ func (r Resolver) Resolve(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, template := &template.Parameters{ StaticParameters: staticParameters, - SelfContainedUserData: imageFamily.SelfContainedUserData( + SelfContainedCustomData: imageFamily.SelfContainedCustomData( prepareKubeletConfiguration(instanceType, nodeClaim), append(nodeClaim.Spec.Taints, nodeClaim.Spec.StartupTaints...), staticParameters.Labels, diff --git a/pkg/providers/imagefamily/ubuntu_2204.go b/pkg/providers/imagefamily/ubuntu_2204.go index 84653d115..fb58a35a0 100644 --- a/pkg/providers/imagefamily/ubuntu_2204.go +++ b/pkg/providers/imagefamily/ubuntu_2204.go @@ -77,7 +77,7 @@ func (u Ubuntu2204) DefaultImages() []DefaultImageOutput { } // UserData returns the default userdata script for the image Family -func (u Ubuntu2204) SelfContainedUserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u Ubuntu2204) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index a19caf0f5..c84017af1 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -364,20 +364,20 @@ func newVMObject( Zones: lo.Ternary(len(zone) > 0, []*string{&zone}, []*string{}), Tags: launchTemplate.Tags, } - setVMPropertiesStorageProfile(vm.Properties, launchTemplate.StorageProfile) + setVMPropertiesOSDiskType(vm.Properties, launchTemplate.StorageProfile) setVMPropertiesBillingProfile(vm.Properties, capacityType) if provisionMode == options.ProvisionModeBootstrappingClient { vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.AgentBakerCustomData) } else { - vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.SelfContainedUserData) + vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.SelfContainedCustomData) } return vm } -// setVMPropertiesStorageProfile enables ephemeral os disk for instance types that support it -func setVMPropertiesStorageProfile(vmProperties *armcompute.VirtualMachineProperties, storageProfile string) { +// setVMPropertiesOSDiskType enables ephemeral os disk for instance types that support it +func setVMPropertiesOSDiskType(vmProperties *armcompute.VirtualMachineProperties, storageProfile string) { if storageProfile == "Ephemeral" { vmProperties.StorageProfile.OSDisk.DiffDiskSettings = &armcompute.DiffDiskSettings{ Option: lo.ToPtr(armcompute.DiffDiskOptionsLocal), @@ -718,38 +718,20 @@ func (p *Provider) getCSExtension(cse string, isWindows bool) *armcompute.Virtua cseVersionLinux = "2.0" ) - if isWindows { // TODO(Windows) - return &armcompute.VirtualMachineExtension{ - Location: lo.ToPtr(p.location), - Name: lo.ToPtr(cseNameWindows), - Type: lo.ToPtr(vmExtensionType), - Properties: &armcompute.VirtualMachineExtensionProperties{ - AutoUpgradeMinorVersion: lo.ToPtr(true), - Type: lo.ToPtr(cseTypeWindows), - Publisher: lo.ToPtr(csePublisherWindows), - TypeHandlerVersion: lo.ToPtr(cseVersionWindows), - Settings: &map[string]interface{}{}, - ProtectedSettings: &map[string]interface{}{ - "commandToExecute": cse, - }, - }, - } - } else { - return &armcompute.VirtualMachineExtension{ - Location: lo.ToPtr(p.location), - Name: lo.ToPtr(cseNameLinux), - Type: lo.ToPtr(vmExtensionType), - Properties: &armcompute.VirtualMachineExtensionProperties{ - AutoUpgradeMinorVersion: lo.ToPtr(true), - Type: lo.ToPtr(cseTypeLinux), - Publisher: lo.ToPtr(csePublisherLinux), - TypeHandlerVersion: lo.ToPtr(cseVersionLinux), - Settings: &map[string]interface{}{}, - ProtectedSettings: &map[string]interface{}{ - "commandToExecute": cse, - }, + return &armcompute.VirtualMachineExtension{ + Location: lo.ToPtr(p.location), + Name: lo.ToPtr(lo.Ternary(isWindows, cseNameWindows, cseNameLinux)), + Type: lo.ToPtr(vmExtensionType), + Properties: &armcompute.VirtualMachineExtensionProperties{ + AutoUpgradeMinorVersion: lo.ToPtr(true), + Type: lo.ToPtr(lo.Ternary(isWindows, cseTypeWindows, cseTypeLinux)), + Publisher: lo.ToPtr(lo.Ternary(isWindows, csePublisherWindows, csePublisherLinux)), + TypeHandlerVersion: lo.ToPtr(lo.Ternary(isWindows, cseVersionWindows, cseVersionLinux)), + Settings: &map[string]interface{}{}, + ProtectedSettings: &map[string]interface{}{ + "commandToExecute": cse, }, - } + }, } } diff --git a/pkg/providers/launchtemplate/launchtemplate.go b/pkg/providers/launchtemplate/launchtemplate.go index 3aaf73ba0..f0d6db5ed 100644 --- a/pkg/providers/launchtemplate/launchtemplate.go +++ b/pkg/providers/launchtemplate/launchtemplate.go @@ -45,14 +45,14 @@ const ( ) type Template struct { - SelfContainedUserData string - ImageID string - SubnetID string - Tags map[string]*string - AgentBakerCustomData string - AgentBakerCSE string - IsWindows bool - StorageProfile string + SelfContainedCustomData string + ImageID string + SubnetID string + Tags map[string]*string + AgentBakerCustomData string + AgentBakerCSE string + IsWindows bool + StorageProfile string } type Provider struct { @@ -188,11 +188,11 @@ func (p *Provider) createLaunchTemplate(ctx context.Context, params *parameters. template.AgentBakerCSE = cse } else { // render user data - userData, err := params.SelfContainedUserData.Script() + userData, err := params.SelfContainedCustomData.Script() if err != nil { return nil, err } - template.SelfContainedUserData = userData + template.SelfContainedCustomData = userData } return template, nil diff --git a/pkg/providers/launchtemplate/parameters/types.go b/pkg/providers/launchtemplate/parameters/types.go index 4d0b96694..8ef609eee 100644 --- a/pkg/providers/launchtemplate/parameters/types.go +++ b/pkg/providers/launchtemplate/parameters/types.go @@ -51,7 +51,7 @@ type StaticParameters struct { // Parameters adds the dynamically generated launch template parameters type Parameters struct { *StaticParameters - SelfContainedUserData bootstrap.Bootstrapper + SelfContainedCustomData bootstrap.Bootstrapper AgentBakerNodeBootstrapping agentbakerbootstrap.Bootstrapper ImageID string StorageProfile string From 7169f33dfbf25631e109b939f5ebc497159317ef Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:37:29 -0700 Subject: [PATCH 04/16] fix: required VnetCidrs wasn't populated --- .../imagefamily/agentbakerbootstrap/provisionclientbootstrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index f93bcd504..6ad231945 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -91,7 +91,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri // EnableSecureBoot: lo.ToPtr(false), // Unsupported as of now (Trusted launch) }, - // VnetCidrs: []string{}, // Unsupported as of now; TODO(Windows) + VnetCidrs: []string{}, // Unsupported as of now; TODO(Windows) // MessageOfTheDay: lo.ToPtr(""), // Unsupported as of now // AgentPoolWindowsProfile: &models.AgentPoolWindowsProfile{}, // Unsupported as of now; TODO(Windows) // KubeletDiskType: lo.ToPtr(models.KubeletDiskType_Unspecified), // Unsupported as of now From c6a76bad6c486f16cff3ca08eec1d87cf4e13460 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:38:05 -0700 Subject: [PATCH 05/16] chore: read error response as text --- .../node_bootstrapping_get_responses.go | 8 +-- pkg/provisionclients/models/error.go | 59 ------------------- .../swagger/nodebootstrapping.json | 20 +------ 3 files changed, 4 insertions(+), 83 deletions(-) delete mode 100644 pkg/provisionclients/models/error.go diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go index 3f5dc19b0..cfbe1e6fe 100644 --- a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go @@ -127,7 +127,7 @@ Error response describing why the operation failed. type NodeBootstrappingGetDefault struct { _statusCode int - Payload *models.Error + Payload string } // IsSuccess returns true when this node bootstrapping get default response has a 2xx status code @@ -170,16 +170,14 @@ func (o *NodeBootstrappingGetDefault) String() string { return fmt.Sprintf("[GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/nodeBootstrapping][%d] NodeBootstrapping_Get default %s", o._statusCode, payload) } -func (o *NodeBootstrappingGetDefault) GetPayload() *models.Error { +func (o *NodeBootstrappingGetDefault) GetPayload() string { return o.Payload } func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.Error) - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { return err } diff --git a/pkg/provisionclients/models/error.go b/pkg/provisionclients/models/error.go deleted file mode 100644 index f7389db90..000000000 --- a/pkg/provisionclients/models/error.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// Error error -// -// swagger:model Error -type Error struct { - - // category - Category string `json:"category,omitempty"` - - // code - Code int32 `json:"code,omitempty"` - - // message - Message string `json:"message,omitempty"` - - // subcode - Subcode string `json:"subcode,omitempty"` -} - -// Validate validates this error -func (m *Error) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this error based on context it is used -func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *Error) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Error) UnmarshalBinary(b []byte) error { - var res Error - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/provisionclients/swagger/nodebootstrapping.json b/pkg/provisionclients/swagger/nodebootstrapping.json index a9cb7ca87..2271bc8fd 100644 --- a/pkg/provisionclients/swagger/nodebootstrapping.json +++ b/pkg/provisionclients/swagger/nodebootstrapping.json @@ -50,7 +50,7 @@ "default": { "description": "Error response describing why the operation failed.", "schema": { - "$ref": "#/definitions/Error" + "type": "string" } } } @@ -628,24 +628,6 @@ "osImageConfig", "sigImageConfig" ] - }, - "Error": { - "type": "object", - "properties": { - "category": { - "type": "string" - }, - "code": { - "type": "integer", - "format": "int32" - }, - "subcode": { - "type": "string" - }, - "message": { - "type": "string" - } - } } }, "parameters": { From 57437230390c86c09a19fcc3577e13b0bbeee312 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:38:24 -0700 Subject: [PATCH 06/16] fix: handle the issue of mismatched error format in response body/header --- .../node_bootstrapping_get_responses.go | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go index cfbe1e6fe..e28868813 100644 --- a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go @@ -177,9 +177,23 @@ func (o *NodeBootstrappingGetDefault) GetPayload() string { func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } + + // THIS IS MODIFIED FROM AUTO-GENERATED. + // There is a known issue on the server side where content type in the header (JSON) doesn't match actual (text). + // This is a work around for that, which should be safe due to the fact that string > JSON. Only affect logging format for now. + // The "consumer" that we replaced only decode into JSON, and unlikely to change. + rc := response.Body() + defer rc.Close() + + bytes, err := io.ReadAll(rc) + if err != nil { + return err + } + o.Payload = string(bytes) + + // if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + // return err + // } return nil } From dc5f6264f38c7efffcbf6f7f6e9309ea1eb16078 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:40:18 -0700 Subject: [PATCH 07/16] chore: more accurate overhead subtraction for instancetype --- pkg/providers/instancetype/instancetype.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/providers/instancetype/instancetype.go b/pkg/providers/instancetype/instancetype.go index abc17cdea..efc06e613 100644 --- a/pkg/providers/instancetype/instancetype.go +++ b/pkg/providers/instancetype/instancetype.go @@ -266,7 +266,7 @@ func getArchitecture(architecture string) string { func computeCapacity(ctx context.Context, sku *skewer.SKU, kc *corev1beta1.KubeletConfiguration, nodeClass *v1alpha2.AKSNodeClass) v1.ResourceList { return v1.ResourceList{ v1.ResourceCPU: *cpu(sku), - v1.ResourceMemory: *memory(ctx, sku), + v1.ResourceMemory: *memoryWithoutOverhead(ctx, sku), v1.ResourceEphemeralStorage: *ephemeralStorage(nodeClass), v1.ResourcePods: *pods(sku, kc), v1.ResourceName("nvidia.com/gpu"): *gpuNvidiaCount(sku), @@ -298,11 +298,11 @@ func memoryMiB(sku *skewer.SKU) int64 { return int64(memoryGiB(sku) * 1024) } -func memory(ctx context.Context, sku *skewer.SKU) *resource.Quantity { +func memoryWithoutOverhead(ctx context.Context, sku *skewer.SKU) *resource.Quantity { memory := resources.Quantity(fmt.Sprintf("%dGi", int64(memoryGiB(sku)))) // Account for VM overhead in calculation - memory.Sub(resource.MustParse(fmt.Sprintf("%dMi", int64(math.Ceil( - float64(memory.Value())*options.FromContext(ctx).VMMemoryOverheadPercent/1024/1024))))) + memory.Sub(*resource.NewQuantity(int64(math.Ceil( + float64(memory.Value())*options.FromContext(ctx).VMMemoryOverheadPercent)), resource.DecimalSI)) return memory } From 62e5c3b7a3937b4ffb4010471dc59484f61a1315 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Thu, 17 Oct 2024 17:40:38 -0700 Subject: [PATCH 08/16] fix: correct VM memory passing --- .../agentbakerbootstrap/provisionclientbootstrap.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index 6ad231945..adff7775c 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -20,6 +20,7 @@ import ( "context" "encoding/base64" "fmt" + "math" "strings" "time" @@ -141,7 +142,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri provisionHelperValues := &models.ProvisionHelperValues{ SkuCPU: lo.ToPtr(p.InstanceType.Capacity.Cpu().AsApproximateFloat64()), - SkuMemory: lo.ToPtr(p.InstanceType.Capacity.Memory().AsApproximateFloat64()), + SkuMemory: lo.ToPtr(math.Ceil(reverseVMMemoryOverhead(ctx, p.InstanceType.Capacity.Memory().AsApproximateFloat64()) / 1024 / 1024 / 1024)), } return p.getNodeBootstrappingFromClient(ctx, provisionProfile, provisionHelperValues, p.KubeletClientTLSBootstrapToken) @@ -220,3 +221,9 @@ func normalizeResourceGroupNameForLabel(resourceGroupName string) string { } return truncated } + +func reverseVMMemoryOverhead(ctx context.Context, adjustedMemory float64) float64 { + // This is not the best way to do it... But will be refactored later, given that retreiving the original memory properly might involves some restructure. + // Due to the fact that it is abstracted behind the cloudprovider interface. + return adjustedMemory / (1 - options.FromContext(ctx).VMMemoryOverheadPercent) +} From 844064792d848da15ff309ca07b16aee2e89ab54 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Fri, 18 Oct 2024 14:27:37 -0700 Subject: [PATCH 09/16] test: some unit tests and improvements --- pkg/operator/options/options.go | 3 +- pkg/operator/options/options_validation.go | 7 ++- pkg/operator/options/suite_test.go | 28 ++++++++++ .../provisionclientbootstrap.go | 11 ++-- .../provisionclientbootstrap_test.go | 55 +++++++++++++++++++ pkg/providers/imagefamily/resolver.go | 5 +- pkg/providers/instance/instance.go | 14 ----- pkg/providers/instance/instance_test.go | 1 + pkg/providers/instancetype/instancetype.go | 10 +++- pkg/test/environment.go | 5 +- pkg/test/options.go | 3 + 11 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go diff --git a/pkg/operator/options/options.go b/pkg/operator/options/options.go index aecb99f32..6867693b3 100644 --- a/pkg/operator/options/options.go +++ b/pkg/operator/options/options.go @@ -57,6 +57,7 @@ func (s *nodeIdentitiesValue) Get() any { return []string(*s) } func (s *nodeIdentitiesValue) String() string { return strings.Join(*s, ",") } const ( + ProvisionModeAKSSelfContained = "aksselfcontained" ProvisionModeBootstrappingClient = "bootstrappingclient" ) @@ -96,7 +97,7 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) { fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR") fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.") fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live") - fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", ""), "[UNSUPPORTED] The provision mode for the cluster.") + fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", "aksselfcontained"), "[UNSUPPORTED] The provision mode for the cluster.") fs.StringVar(&o.NodeBootstrappingServerURL, "nodebootstrapping-server-url", env.WithDefaultString("NODEBOOTSTRAPPING_SERVER_URL", ""), "[UNSUPPORTED] The url for the node bootstrapping provider server.") } diff --git a/pkg/operator/options/options_validation.go b/pkg/operator/options/options_validation.go index 0acf7b304..36e748094 100644 --- a/pkg/operator/options/options_validation.go +++ b/pkg/operator/options/options_validation.go @@ -85,9 +85,14 @@ func (o Options) validateVMMemoryOverheadPercent() error { } func (o Options) validateProvisionMode() error { - if o.ProvisionMode != "" && o.ProvisionMode != "bootstrappingclient" { + if o.ProvisionMode != ProvisionModeAKSSelfContained && o.ProvisionMode != ProvisionModeBootstrappingClient { return fmt.Errorf("provision-mode is invalid: %s", o.ProvisionMode) } + if o.ProvisionMode == ProvisionModeBootstrappingClient { + if o.NodeBootstrappingServerURL == "" { + return fmt.Errorf("nodebootstrapping-server-url is required when provision-mode is bootstrappingclient") + } + } return nil } diff --git a/pkg/operator/options/suite_test.go b/pkg/operator/options/suite_test.go index 9037e2dfc..fa780fabc 100644 --- a/pkg/operator/options/suite_test.go +++ b/pkg/operator/options/suite_test.go @@ -53,6 +53,8 @@ var _ = Describe("Options", func() { "NETWORK_PLUGIN", "NETWORK_POLICY", "NODE_IDENTITIES", + "PROVISION_MODE", + "NODEBOOTSTRAPPING_SERVER_URL", } var fs *coreoptions.FlagSet @@ -95,6 +97,8 @@ var _ = Describe("Options", func() { os.Setenv("NETWORK_POLICY", "env-network-policy") os.Setenv("NODE_IDENTITIES", "/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid1,/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid2") os.Setenv("VNET_SUBNET_ID", "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub") + os.Setenv("PROVISION_MODE", "bootstrappingclient") + os.Setenv("NODEBOOTSTRAPPING_SERVER_URL", "https://nodebootstrapping-server-url") fs = &coreoptions.FlagSet{ FlagSet: flag.NewFlagSet("karpenter", flag.ContinueOnError), } @@ -112,6 +116,8 @@ var _ = Describe("Options", func() { NetworkPolicy: lo.ToPtr("env-network-policy"), SubnetID: lo.ToPtr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub"), NodeIdentities: []string{"/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid1", "/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid2"}, + ProvisionMode: lo.ToPtr("bootstrappingclient"), + NodeBootstrappingServerURL: lo.ToPtr("https://nodebootstrapping-server-url"), })) }) }) @@ -273,6 +279,28 @@ var _ = Describe("Options", func() { ) Expect(err).ToNot(HaveOccurred()) }) + It("should fail validation when ProvisionMode is not valid", func() { + err := opts.Parse( + fs, + "--cluster-name", "my-name", + "--cluster-endpoint", "https://karpenter-000000000000.hcp.westus2.staging.azmk8s.io", + "--kubelet-bootstrap-token", "flag-bootstrap-token", + "--ssh-public-key", "flag-ssh-public-key", + "--provision-mode", "ekeselfexposed", + ) + Expect(err).To(MatchError(ContainSubstring("provision-mode"))) + }) + It("should fail validation when ProvisionMode is bootstrappingclient but NodebootstrappingServerURL is not provided", func() { + err := opts.Parse( + fs, + "--cluster-name", "my-name", + "--cluster-endpoint", "https://karpenter-000000000000.hcp.westus2.staging.azmk8s.io", + "--kubelet-bootstrap-token", "flag-bootstrap-token", + "--ssh-public-key", "flag-ssh-public-key", + "--provision-mode", "bootstrappingclient", + ) + Expect(err).To(MatchError(ContainSubstring("nodebootstrapping-server-url"))) + }) }) }) diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index adff7775c..9ed6c5373 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -32,7 +32,6 @@ import ( "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/models" "github.com/Azure/karpenter-provider-azure/pkg/utils" - core "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" @@ -46,8 +45,8 @@ import ( type ProvisionClientBootstrap struct { ClusterName string KubeletConfig *corev1beta1.KubeletConfiguration - Taints []core.Taint `hash:"set"` - StartupTaints []core.Taint `hash:"set"` + Taints []v1.Taint `hash:"set"` + StartupTaints []v1.Taint `hash:"set"` Labels map[string]string `hash:"set"` SubnetID string Arch string @@ -142,7 +141,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri provisionHelperValues := &models.ProvisionHelperValues{ SkuCPU: lo.ToPtr(p.InstanceType.Capacity.Cpu().AsApproximateFloat64()), - SkuMemory: lo.ToPtr(math.Ceil(reverseVMMemoryOverhead(ctx, p.InstanceType.Capacity.Memory().AsApproximateFloat64()) / 1024 / 1024 / 1024)), + SkuMemory: lo.ToPtr(math.Ceil(reverseVMMemoryOverhead(options.FromContext(ctx).VMMemoryOverheadPercent, p.InstanceType.Capacity.Memory().AsApproximateFloat64()) / 1024 / 1024 / 1024)), } return p.getNodeBootstrappingFromClient(ctx, provisionProfile, provisionHelperValues, p.KubeletClientTLSBootstrapToken) @@ -222,8 +221,8 @@ func normalizeResourceGroupNameForLabel(resourceGroupName string) string { return truncated } -func reverseVMMemoryOverhead(ctx context.Context, adjustedMemory float64) float64 { +func reverseVMMemoryOverhead(vmMemoryOverheadPercent float64, adjustedMemory float64) float64 { // This is not the best way to do it... But will be refactored later, given that retreiving the original memory properly might involves some restructure. // Due to the fact that it is abstracted behind the cloudprovider interface. - return adjustedMemory / (1 - options.FromContext(ctx).VMMemoryOverheadPercent) + return adjustedMemory / (1 - vmMemoryOverheadPercent) } diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go new file mode 100644 index 000000000..8e0cd79d7 --- /dev/null +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go @@ -0,0 +1,55 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package agentbakerbootstrap + +import ( + "fmt" + "math" + "testing" + + "github.com/Azure/karpenter-provider-azure/pkg/providers/instancetype" +) + +func TestReverseVMMemoryOverhead(t *testing.T) { + type Cases struct { + name string + originalGiB int64 + vmMemoryOverheadPercent float64 + } + var cases []Cases + + // Generate test cases from originalGiB 1 to 2000 x vmMemoryOverheadPercent 0 to 0.25 using for loops + // In fact, mathematically, the reverse won't be perfectly equal, but current accuracy in GiB should be enough + for i := 1; i <= 2000; i++ { + for j := 0; j <= 250; j++ { + cases = append(cases, Cases{ + name: fmt.Sprintf("Test %d - %f", i, float64(j)/1000), + originalGiB: int64(i), + vmMemoryOverheadPercent: float64(j) / 1000, + }) + } + } + t.Run("2000 x 0.25", func(t *testing.T) { + for _, tc := range cases { + subtracted := instancetype.CalculateMemoryWithoutOverhead(tc.vmMemoryOverheadPercent, float64(tc.originalGiB)).Value() + reversedGiB := int64(math.Round(reverseVMMemoryOverhead(tc.vmMemoryOverheadPercent, float64(subtracted)) / 1024 / 1024 / 1024)) + if tc.originalGiB != reversedGiB { + t.Errorf("Expected %d but got %d", tc.originalGiB, reversedGiB) + } + } + }) +} diff --git a/pkg/providers/imagefamily/resolver.go b/pkg/providers/imagefamily/resolver.go index 6b416bb96..cad6f113f 100644 --- a/pkg/providers/imagefamily/resolver.go +++ b/pkg/providers/imagefamily/resolver.go @@ -34,7 +34,6 @@ import ( "github.com/samber/lo" corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" "sigs.k8s.io/karpenter/pkg/cloudprovider" - corecloudprovider "sigs.k8s.io/karpenter/pkg/cloudprovider" "sigs.k8s.io/karpenter/pkg/utils/resources" ) @@ -142,7 +141,7 @@ func getImageFamily(familyName *string, parameters *template.StaticParameters) I } } -func getEphemeralMaxSizeGB(instanceType *corecloudprovider.InstanceType) int32 { +func getEphemeralMaxSizeGB(instanceType *cloudprovider.InstanceType) int32 { reqs := instanceType.Requirements.Get(v1alpha2.LabelSKUStorageEphemeralOSMaxSize).Values() if len(reqs) == 0 || len(reqs) > 1 { return 0 @@ -156,7 +155,7 @@ func getEphemeralMaxSizeGB(instanceType *corecloudprovider.InstanceType) int32 { } // setVMPropertiesStorageProfile enables ephemeral os disk for instance types that support it -func useEphemeralDisk(instanceType *corecloudprovider.InstanceType, nodeClass *v1alpha2.AKSNodeClass) bool { +func useEphemeralDisk(instanceType *cloudprovider.InstanceType, nodeClass *v1alpha2.AKSNodeClass) bool { // use ephemeral disk if it is large enough return *nodeClass.Spec.OSDiskSizeGB <= getEphemeralMaxSizeGB(instanceType) } diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index c84017af1..606c056a2 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -23,7 +23,6 @@ import ( "fmt" "math" "sort" - "strconv" "strings" "time" @@ -542,19 +541,6 @@ func (p *Provider) handleResponseErrors(ctx context.Context, instanceType *corec return err } -func getEphemeralMaxSizeGB(instanceType *corecloudprovider.InstanceType) int32 { - reqs := instanceType.Requirements.Get(v1alpha2.LabelSKUStorageEphemeralOSMaxSize).Values() - if len(reqs) == 0 || len(reqs) > 1 { - return 0 - } - maxSize, err := strconv.ParseFloat(reqs[0], 32) - if err != nil { - return 0 - } - // decimal places are truncated, so we round down - return int32(maxSize) -} - func cpuLimitIsZero(err error) bool { return strings.Contains(err.Error(), "Current Limit: 0") } diff --git a/pkg/providers/instance/instance_test.go b/pkg/providers/instance/instance_test.go index 57e35e340..4a98735dc 100644 --- a/pkg/providers/instance/instance_test.go +++ b/pkg/providers/instance/instance_test.go @@ -81,6 +81,7 @@ func TestGetPriorityCapacityAndInstanceType(t *testing.T) { "westus-2", "MC_xxxxx_yyyy-region", "0000000-0000-0000-0000-0000000000", + "", ) for _, c := range cases { t.Run(c.name, func(t *testing.T) { diff --git a/pkg/providers/instancetype/instancetype.go b/pkg/providers/instancetype/instancetype.go index efc06e613..49655eb8c 100644 --- a/pkg/providers/instancetype/instancetype.go +++ b/pkg/providers/instancetype/instancetype.go @@ -299,10 +299,14 @@ func memoryMiB(sku *skewer.SKU) int64 { } func memoryWithoutOverhead(ctx context.Context, sku *skewer.SKU) *resource.Quantity { - memory := resources.Quantity(fmt.Sprintf("%dGi", int64(memoryGiB(sku)))) - // Account for VM overhead in calculation + return CalculateMemoryWithoutOverhead(options.FromContext(ctx).VMMemoryOverheadPercent, memoryGiB(sku)) +} + +func CalculateMemoryWithoutOverhead(vmMemoryOverheadPercent float64, skuMemoryGiB float64) *resource.Quantity { + // Consistency in abstractions could be improved here (e.g., units, returning types) + memory := resources.Quantity(fmt.Sprintf("%dGi", int64(skuMemoryGiB))) memory.Sub(*resource.NewQuantity(int64(math.Ceil( - float64(memory.Value())*options.FromContext(ctx).VMMemoryOverheadPercent)), resource.DecimalSI)) + float64(memory.Value())*vmMemoryOverheadPercent)), resource.DecimalSI)) return memory } diff --git a/pkg/test/environment.go b/pkg/test/environment.go index d4c2141d6..bd821b0dc 100644 --- a/pkg/test/environment.go +++ b/pkg/test/environment.go @@ -119,10 +119,12 @@ func NewRegionalEnvironment(ctx context.Context, env *coretest.Environment, regi testOptions.ClusterEndpoint, "test-tenant", "test-subscription", - "test-userAssignedIdentity", + "test-cluster-resource-group", + "test-kubelet-identity-client-id", testOptions.NodeResourceGroup, region, "test-vnet-guid", + testOptions.ProvisionMode, ) loadBalancerProvider := loadbalancer.NewProvider( loadBalancersAPI, @@ -147,6 +149,7 @@ func NewRegionalEnvironment(ctx context.Context, env *coretest.Environment, regi region, testOptions.NodeResourceGroup, "", // subscriptionID + testOptions.ProvisionMode, ) return &Environment{ diff --git a/pkg/test/options.go b/pkg/test/options.go index ab0a10ba7..e8ff20202 100644 --- a/pkg/test/options.go +++ b/pkg/test/options.go @@ -39,6 +39,8 @@ type OptionsFields struct { NodeIdentities []string SubnetID *string NodeResourceGroup *string + ProvisionMode *string + NodeBootstrappingServerURL *string } func Options(overrides ...OptionsFields) *azoptions.Options { @@ -62,5 +64,6 @@ func Options(overrides ...OptionsFields) *azoptions.Options { NodeIdentities: options.NodeIdentities, SubnetID: lo.FromPtrOr(options.SubnetID, "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub"), NodeResourceGroup: lo.FromPtrOr(options.NodeResourceGroup, "test-resourceGroup"), + ProvisionMode: lo.FromPtrOr(options.ProvisionMode, "aksselfcontained"), } } From 425a55a0efa118e3a0c70d5773b4334be93aae89 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Fri, 18 Oct 2024 15:09:03 -0700 Subject: [PATCH 10/16] chore: linter changes and small improvements --- .../provisionclientbootstrap.go | 22 ++++----- .../client/node_bootstrapping_client.go | 15 ++++++ .../node_bootstrapping_get_parameters.go | 15 ++++++ .../node_bootstrapping_get_responses.go | 38 ++++++--------- ...de_bootstrapping_get_responses_override.go | 48 +++++++++++++++++++ .../client/operations/operations_client.go | 15 ++++++ .../models/agent_pool_security_profile.go | 15 ++++++ .../models/agent_pool_windows_profile.go | 15 ++++++ .../models/artifact_streaming_profile.go | 15 ++++++ .../models/azure_o_s_image_config.go | 15 ++++++ .../models/custom_kubelet_config.go | 15 ++++++ .../models/custom_linux_o_s_config.go | 15 ++++++ pkg/provisionclients/models/enums.go | 46 +++++++++--------- pkg/provisionclients/models/g_p_u_profile.go | 15 ++++++ .../models/node_bootstrapping.go | 15 ++++++ .../models/provision_helper_values.go | 15 ++++++ .../models/provision_profile.go | 15 ++++++ .../models/provision_values.go | 15 ++++++ .../models/sig_image_config.go | 15 ++++++ .../models/sig_image_config_template.go | 15 ++++++ pkg/provisionclients/models/sysctl_config.go | 15 ++++++ pkg/provisionclients/models/ulimit_config.go | 15 ++++++ 22 files changed, 368 insertions(+), 56 deletions(-) create mode 100644 pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index 9ed6c5373..2ad37511d 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -76,7 +76,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri provisionProfile := &models.ProvisionProfile{ Name: lo.ToPtr(""), Architecture: lo.ToPtr(lo.Ternary(p.Arch == corev1beta1.ArchitectureAmd64, "x64", "Arm64")), - OsType: lo.ToPtr(lo.Ternary(p.IsWindows, models.OSType_Windows, models.OSType_Linux)), + OsType: lo.ToPtr(lo.Ternary(p.IsWindows, models.OSTypeWindows, models.OSTypeLinux)), VMSize: lo.ToPtr(p.InstanceType.Name), Distro: lo.ToPtr(p.ImageDistro), CustomNodeLabels: labels, @@ -86,7 +86,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri NodeInitializationTaints: lo.Map(p.StartupTaints, func(taint v1.Taint, _ int) string { return taint.ToString() }), NodeTaints: lo.Map(p.Taints, func(taint v1.Taint, _ int) string { return taint.ToString() }), SecurityProfile: &models.AgentPoolSecurityProfile{ - SSHAccess: lo.ToPtr(models.SSHAccess_LocalUser), + SSHAccess: lo.ToPtr(models.SSHAccessLocalUser), // EnableVTPM: lo.ToPtr(false), // Unsupported as of now (Trusted launch) // EnableSecureBoot: lo.ToPtr(false), // Unsupported as of now (Trusted launch) }, @@ -94,11 +94,11 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri VnetCidrs: []string{}, // Unsupported as of now; TODO(Windows) // MessageOfTheDay: lo.ToPtr(""), // Unsupported as of now // AgentPoolWindowsProfile: &models.AgentPoolWindowsProfile{}, // Unsupported as of now; TODO(Windows) - // KubeletDiskType: lo.ToPtr(models.KubeletDiskType_Unspecified), // Unsupported as of now + // KubeletDiskType: lo.ToPtr(models.KubeletDiskTypeUnspecified), // Unsupported as of now // CustomLinuxOSConfig: &models.CustomLinuxOSConfig{}, // Unsupported as of now (sysctl) // EnableFIPS: lo.ToPtr(false), // Unsupported as of now - // GpuInstanceProfile: lo.ToPtr(models.GPUInstanceProfile_Unspecified), // Unsupported as of now (MIG) - // WorkloadRuntime: lo.ToPtr(models.WorkloadRuntime_Unspecified), // Unsupported as of now (Kata) + // GpuInstanceProfile: lo.ToPtr(models.GPUInstanceProfileUnspecified), // Unsupported as of now (MIG) + // WorkloadRuntime: lo.ToPtr(models.WorkloadRuntimeUnspecified), // Unsupported as of now (Kata) // ArtifactStreamingProfile: &models.ArtifactStreamingProfile{ // Enabled: lo.ToPtr(false), // Unsupported as of now // }, @@ -106,11 +106,11 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri switch p.ImageFamily { case v1alpha2.Ubuntu2204ImageFamily: - provisionProfile.OsSku = to.Ptr(models.OSSKU_Ubuntu) + provisionProfile.OsSku = to.Ptr(models.OSSKUUbuntu) case v1alpha2.AzureLinuxImageFamily: - provisionProfile.OsSku = to.Ptr(models.OSSKU_AzureLinux) + provisionProfile.OsSku = to.Ptr(models.OSSKUAzureLinux) default: - provisionProfile.OsSku = to.Ptr(models.OSSKU_Ubuntu) + provisionProfile.OsSku = to.Ptr(models.OSSKUUbuntu) } if p.KubeletConfig != nil { @@ -127,14 +127,14 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri } if modeString, ok := p.Labels["kubernetes.azure.com/mode"]; ok && modeString == "system" { - provisionProfile.Mode = lo.ToPtr(models.AgentPoolMode_System) + provisionProfile.Mode = lo.ToPtr(models.AgentPoolModeSystem) } else { - provisionProfile.Mode = lo.ToPtr(models.AgentPoolMode_User) + provisionProfile.Mode = lo.ToPtr(models.AgentPoolModeUser) } if utils.IsNvidiaEnabledSKU(p.InstanceType.Name) { provisionProfile.GpuProfile = &models.GPUProfile{ - DriverType: lo.ToPtr(lo.Ternary(utils.UseGridDrivers(p.InstanceType.Name), models.DriverType_GRID, models.DriverType_CUDA)), + DriverType: lo.ToPtr(lo.Ternary(utils.UseGridDrivers(p.InstanceType.Name), models.DriverTypeGRID, models.DriverTypeCUDA)), InstallGPUDriver: lo.ToPtr(true), } } diff --git a/pkg/provisionclients/client/node_bootstrapping_client.go b/pkg/provisionclients/client/node_bootstrapping_client.go index e74efc268..2bd257a8b 100644 --- a/pkg/provisionclients/client/node_bootstrapping_client.go +++ b/pkg/provisionclients/client/node_bootstrapping_client.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package client diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go index e67f2f5e5..72168cc4a 100644 --- a/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_parameters.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package operations diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go index e28868813..86e75f225 100644 --- a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package operations @@ -174,26 +189,3 @@ func (o *NodeBootstrappingGetDefault) GetPayload() string { return o.Payload } -func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - - // THIS IS MODIFIED FROM AUTO-GENERATED. - // There is a known issue on the server side where content type in the header (JSON) doesn't match actual (text). - // This is a work around for that, which should be safe due to the fact that string > JSON. Only affect logging format for now. - // The "consumer" that we replaced only decode into JSON, and unlikely to change. - rc := response.Body() - defer rc.Close() - - bytes, err := io.ReadAll(rc) - if err != nil { - return err - } - o.Payload = string(bytes) - - // if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - // return err - // } - - return nil -} diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go new file mode 100644 index 000000000..46c970741 --- /dev/null +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go @@ -0,0 +1,48 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package operations + +import ( + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + + // THIS IS MODIFIED FROM AUTO-GENERATED. + // There is a known issue on the server side where content type in the header (JSON) doesn't match actual (text). + // This is a work around for that, which should be safe due to the fact that string > JSON. Only affect logging format for now. + // The "consumer" that we replaced only decode into JSON, and unlikely to change. + rc := response.Body() + defer rc.Close() + + bytes, err := io.ReadAll(rc) + if err != nil { + return err + } + o.Payload = string(bytes) + + // if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + // return err + // } + + return nil +} diff --git a/pkg/provisionclients/client/operations/operations_client.go b/pkg/provisionclients/client/operations/operations_client.go index a0166e378..8b2778624 100644 --- a/pkg/provisionclients/client/operations/operations_client.go +++ b/pkg/provisionclients/client/operations/operations_client.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package operations diff --git a/pkg/provisionclients/models/agent_pool_security_profile.go b/pkg/provisionclients/models/agent_pool_security_profile.go index 17250c1f5..1f2ca6c98 100644 --- a/pkg/provisionclients/models/agent_pool_security_profile.go +++ b/pkg/provisionclients/models/agent_pool_security_profile.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/agent_pool_windows_profile.go b/pkg/provisionclients/models/agent_pool_windows_profile.go index 4ced2fdc2..f7720daeb 100644 --- a/pkg/provisionclients/models/agent_pool_windows_profile.go +++ b/pkg/provisionclients/models/agent_pool_windows_profile.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/artifact_streaming_profile.go b/pkg/provisionclients/models/artifact_streaming_profile.go index 73a51b15a..8eb413394 100644 --- a/pkg/provisionclients/models/artifact_streaming_profile.go +++ b/pkg/provisionclients/models/artifact_streaming_profile.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/azure_o_s_image_config.go b/pkg/provisionclients/models/azure_o_s_image_config.go index 04190131e..a8ed719bd 100644 --- a/pkg/provisionclients/models/azure_o_s_image_config.go +++ b/pkg/provisionclients/models/azure_o_s_image_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/custom_kubelet_config.go b/pkg/provisionclients/models/custom_kubelet_config.go index 637030286..44dc8c1ef 100644 --- a/pkg/provisionclients/models/custom_kubelet_config.go +++ b/pkg/provisionclients/models/custom_kubelet_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/custom_linux_o_s_config.go b/pkg/provisionclients/models/custom_linux_o_s_config.go index 325149255..57c1bb1ba 100644 --- a/pkg/provisionclients/models/custom_linux_o_s_config.go +++ b/pkg/provisionclients/models/custom_linux_o_s_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/enums.go b/pkg/provisionclients/models/enums.go index ea5406512..35a61ae5c 100644 --- a/pkg/provisionclients/models/enums.go +++ b/pkg/provisionclients/models/enums.go @@ -14,50 +14,52 @@ See the License for the specific language governing permissions and limitations under the License. */ +// This is NOT auto-generated. + package models const ( - OSType_Unspecified int32 = 0 - OSType_Windows int32 = 1 - OSType_Linux int32 = 2 + OSTypeUnspecified int32 = 0 + OSTypeWindows int32 = 1 + OSTypeLinux int32 = 2 ) const ( - OSSKU_Unspecified int32 = 0 - OSSKU_Ubuntu int32 = 1 - OSSKU_AzureLinux int32 = 7 - OSSKU_Windows2019 int32 = 3 - OSSKU_Windows2022 int32 = 4 - OSSKU_WindowsAnnual int32 = 8 + OSSKUUnspecified int32 = 0 + OSSKUUbuntu int32 = 1 + OSSKUAzureLinux int32 = 7 + OSSKUWindows2019 int32 = 3 + OSSKUWindows2022 int32 = 4 + OSSKUWindowsAnnual int32 = 8 ) const ( - KubeletDiskType_Unspecified int32 = 0 - KubeletDiskType_OS int32 = 1 - KubeletDiskType_Temporary int32 = 2 + KubeletDiskTypeUnspecified int32 = 0 + KubeletDiskTypeOS int32 = 1 + KubeletDiskTypeTemporary int32 = 2 ) const ( - AgentPoolMode_Unspecified int32 = 0 - AgentPoolMode_System int32 = 1 - AgentPoolMode_User int32 = 2 + AgentPoolModeUnspecified int32 = 0 + AgentPoolModeSystem int32 = 1 + AgentPoolModeUser int32 = 2 ) const ( - GPUInstanceProfile_Unspecified int32 = 0 + GPUInstanceProfileUnspecified int32 = 0 ) const ( - WorkloadRuntime_Unspecified int32 = 0 + WorkloadRuntimeUnspecified int32 = 0 ) const ( - SSHAccess_LocalUser int32 = 0 - SSHAccess_Disabled int32 = 1 + SSHAccessLocalUser int32 = 0 + SSHAccessDisabled int32 = 1 ) const ( - DriverType_Unspecified int32 = 0 - DriverType_GRID int32 = 2 - DriverType_CUDA int32 = 3 + DriverTypeUnspecified int32 = 0 + DriverTypeGRID int32 = 2 + DriverTypeCUDA int32 = 3 ) diff --git a/pkg/provisionclients/models/g_p_u_profile.go b/pkg/provisionclients/models/g_p_u_profile.go index e664ca8fd..40e1fbe9f 100644 --- a/pkg/provisionclients/models/g_p_u_profile.go +++ b/pkg/provisionclients/models/g_p_u_profile.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/node_bootstrapping.go b/pkg/provisionclients/models/node_bootstrapping.go index 44cc9ae2c..0fc7dfcff 100644 --- a/pkg/provisionclients/models/node_bootstrapping.go +++ b/pkg/provisionclients/models/node_bootstrapping.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/provision_helper_values.go b/pkg/provisionclients/models/provision_helper_values.go index a06e825a5..a86782d55 100644 --- a/pkg/provisionclients/models/provision_helper_values.go +++ b/pkg/provisionclients/models/provision_helper_values.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/provision_profile.go b/pkg/provisionclients/models/provision_profile.go index f93fee777..690b279e7 100644 --- a/pkg/provisionclients/models/provision_profile.go +++ b/pkg/provisionclients/models/provision_profile.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/provision_values.go b/pkg/provisionclients/models/provision_values.go index aa1473e6f..bbfc5aa32 100644 --- a/pkg/provisionclients/models/provision_values.go +++ b/pkg/provisionclients/models/provision_values.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/sig_image_config.go b/pkg/provisionclients/models/sig_image_config.go index 9379d2420..dcbeca86f 100644 --- a/pkg/provisionclients/models/sig_image_config.go +++ b/pkg/provisionclients/models/sig_image_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/sig_image_config_template.go b/pkg/provisionclients/models/sig_image_config_template.go index 3c2e8fc98..d064f02f3 100644 --- a/pkg/provisionclients/models/sig_image_config_template.go +++ b/pkg/provisionclients/models/sig_image_config_template.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/sysctl_config.go b/pkg/provisionclients/models/sysctl_config.go index 00ab75483..1c7354f85 100644 --- a/pkg/provisionclients/models/sysctl_config.go +++ b/pkg/provisionclients/models/sysctl_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models diff --git a/pkg/provisionclients/models/ulimit_config.go b/pkg/provisionclients/models/ulimit_config.go index c36532f50..7c554b81c 100644 --- a/pkg/provisionclients/models/ulimit_config.go +++ b/pkg/provisionclients/models/ulimit_config.go @@ -1,3 +1,18 @@ +/* +Portions Copyright (c) Microsoft Corporation. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ // Code generated by go-swagger; DO NOT EDIT. package models From 45cd0c0ab4544c67425814d9d83162b5d45e24dd Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Fri, 18 Oct 2024 15:21:41 -0700 Subject: [PATCH 11/16] feat: makefile command for swagger client generation --- Makefile | 1 + Makefile-az.mk | 8 ++++++++ .../temp_fix_get_bootstrapping_resp_error.sh | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100755 hack/azure/temp_fix_get_bootstrapping_resp_error.sh diff --git a/Makefile b/Makefile index 3a93ed537..415efd176 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ coverage: go tool cover -html coverage.out -o coverage.html verify: toolchain tidy download ## Verify code. Includes dependencies, linting, formatting, etc + make az-swagger-generate-clients-raw go generate ./... hack/boilerplate.sh cp $(KARPENTER_CORE_DIR)/pkg/apis/crds/* pkg/apis/crds diff --git a/Makefile-az.mk b/Makefile-az.mk index 3e99a73d3..9feaed157 100755 --- a/Makefile-az.mk +++ b/Makefile-az.mk @@ -358,3 +358,11 @@ az-helm-install-snapshot: az-configure-values ## Install Karpenter snapshot rele az-rmcrds: ## Delete Karpenter CRDs kubectl delete crd nodepools.karpenter.sh nodeclaims.karpenter.sh aksnodeclasses.karpenter.azure.com + +az-swagger-generate-clients-raw: + cd pkg/provisionclients && swagger generate client -f swagger/*.json + hack/azure/temp_fix_get_bootstrapping_resp_error.sh + +az-swagger-generate-clients: az-swagger-generate-clients-raw + hack/boilerplate.sh + make tidy diff --git a/hack/azure/temp_fix_get_bootstrapping_resp_error.sh b/hack/azure/temp_fix_get_bootstrapping_resp_error.sh new file mode 100755 index 000000000..28b00633c --- /dev/null +++ b/hack/azure/temp_fix_get_bootstrapping_resp_error.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Define the file path +FILE="pkg/provisionclients/client/operations/node_bootstrapping_get_responses.go" + +# Check if the file exists +if [ ! -f "$FILE" ]; then + echo "File $FILE does not exist." + exit 1 +fi + +# Use sed to delete the readResponse() method if it exists +sed -i '/func (o \*NodeBootstrappingGetDefault) readResponse/,/^}/d' "$FILE" + +echo "readResponse() method deleted from $FILE if it existed. This is for a temporary fix that is in node_bootstrapping_get_responses_override.go." \ No newline at end of file From 049640cd1f7814c0de86351118a25e699049a9ee Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Fri, 18 Oct 2024 15:24:37 -0700 Subject: [PATCH 12/16] chore: remove unused parameters in readResponse() --- .../operations/node_bootstrapping_get_responses_override.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go index 46c970741..93d100035 100644 --- a/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go +++ b/pkg/provisionclients/client/operations/node_bootstrapping_get_responses_override.go @@ -23,8 +23,7 @@ import ( "github.com/go-openapi/strfmt" ) -func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - +func (o *NodeBootstrappingGetDefault) readResponse(response runtime.ClientResponse, _ runtime.Consumer, _ strfmt.Registry) error { // response payload // THIS IS MODIFIED FROM AUTO-GENERATED. From ff4706a1871c11f60326ccc2e21c0f3424944c2f Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Fri, 18 Oct 2024 16:31:49 -0700 Subject: [PATCH 13/16] fix: swagger binary not found --- hack/toolchain.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/hack/toolchain.sh b/hack/toolchain.sh index 1d19ed0e6..c2e9540b7 100755 --- a/hack/toolchain.sh +++ b/hack/toolchain.sh @@ -24,6 +24,7 @@ tools() { go install github.com/rhysd/actionlint/cmd/actionlint@v1.6.27 go install github.com/mattn/goveralls@v0.0.12 go install github.com/google/go-containerregistry/cmd/crane@v0.19.1 + go install github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'." From a5c8403903bece8386c38437a5a899c42a4fd093 Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Sat, 19 Oct 2024 01:31:12 -0700 Subject: [PATCH 14/16] chore: small improvements --- pkg/consts/consts.go | 3 +++ pkg/operator/options/options.go | 7 +------ pkg/operator/options/options_validation.go | 4 ++-- .../agentbakerbootstrap/provisionclientbootstrap.go | 3 ++- pkg/providers/instance/instance.go | 4 ++-- pkg/providers/launchtemplate/launchtemplate.go | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index bdb45c3b0..37ddebe2f 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -28,4 +28,7 @@ const ( NetworkDataplaneAzure = "azure" DefaultKubernetesMaxPods = 250 + + ProvisionModeAKSSelfContained = "aksselfcontained" + ProvisionModeBootstrappingClient = "bootstrappingclient" ) diff --git a/pkg/operator/options/options.go b/pkg/operator/options/options.go index 6867693b3..d417b29dc 100644 --- a/pkg/operator/options/options.go +++ b/pkg/operator/options/options.go @@ -56,11 +56,6 @@ func (s *nodeIdentitiesValue) Get() any { return []string(*s) } func (s *nodeIdentitiesValue) String() string { return strings.Join(*s, ",") } -const ( - ProvisionModeAKSSelfContained = "aksselfcontained" - ProvisionModeBootstrappingClient = "bootstrappingclient" -) - type optionsKey struct{} type Options struct { @@ -97,7 +92,7 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) { fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR") fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.") fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live") - fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", "aksselfcontained"), "[UNSUPPORTED] The provision mode for the cluster.") + fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", consts.ProvisionModeAKSSelfContained), "[UNSUPPORTED] The provision mode for the cluster.") fs.StringVar(&o.NodeBootstrappingServerURL, "nodebootstrapping-server-url", env.WithDefaultString("NODEBOOTSTRAPPING_SERVER_URL", ""), "[UNSUPPORTED] The url for the node bootstrapping provider server.") } diff --git a/pkg/operator/options/options_validation.go b/pkg/operator/options/options_validation.go index 36e748094..cbcc993e2 100644 --- a/pkg/operator/options/options_validation.go +++ b/pkg/operator/options/options_validation.go @@ -85,10 +85,10 @@ func (o Options) validateVMMemoryOverheadPercent() error { } func (o Options) validateProvisionMode() error { - if o.ProvisionMode != ProvisionModeAKSSelfContained && o.ProvisionMode != ProvisionModeBootstrappingClient { + if o.ProvisionMode != consts.ProvisionModeAKSSelfContained && o.ProvisionMode != consts.ProvisionModeBootstrappingClient { return fmt.Errorf("provision-mode is invalid: %s", o.ProvisionMode) } - if o.ProvisionMode == ProvisionModeBootstrappingClient { + if o.ProvisionMode == consts.ProvisionModeBootstrappingClient { if o.NodeBootstrappingServerURL == "" { return fmt.Errorf("nodebootstrapping-server-url is required when provision-mode is bootstrappingclient") } diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go index 2ad37511d..bba3b3fbe 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go @@ -26,6 +26,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" + "github.com/Azure/karpenter-provider-azure/pkg/consts" "github.com/Azure/karpenter-provider-azure/pkg/operator/options" "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/client" "github.com/Azure/karpenter-provider-azure/pkg/provisionclients/client/operations" @@ -123,7 +124,7 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri if p.KubeletConfig != nil && p.KubeletConfig.MaxPods != nil { provisionProfile.MaxPods = p.KubeletConfig.MaxPods } else { - provisionProfile.MaxPods = lo.ToPtr(int32(250)) // Delegatable defaulting? + provisionProfile.MaxPods = lo.ToPtr(int32(consts.DefaultKubernetesMaxPods)) // Delegatable defaulting? } if modeString, ok := p.Labels["kubernetes.azure.com/mode"]; ok && modeString == "system" { diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index 606c056a2..89c69406e 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -366,7 +366,7 @@ func newVMObject( setVMPropertiesOSDiskType(vm.Properties, launchTemplate.StorageProfile) setVMPropertiesBillingProfile(vm.Properties, capacityType) - if provisionMode == options.ProvisionModeBootstrappingClient { + if provisionMode == consts.ProvisionModeBootstrappingClient { vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.AgentBakerCustomData) } else { vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.SelfContainedCustomData) @@ -461,7 +461,7 @@ func (p *Provider) launchInstance( return nil, nil, azErr } - if p.provisionMode == options.ProvisionModeBootstrappingClient { + if p.provisionMode == consts.ProvisionModeBootstrappingClient { err = p.createCSExtension(ctx, resourceName, launchTemplate.AgentBakerCSE, launchTemplate.IsWindows) if err != nil { // This should fall back to cleanupAzureResources diff --git a/pkg/providers/launchtemplate/launchtemplate.go b/pkg/providers/launchtemplate/launchtemplate.go index f0d6db5ed..5545f02f0 100644 --- a/pkg/providers/launchtemplate/launchtemplate.go +++ b/pkg/providers/launchtemplate/launchtemplate.go @@ -179,7 +179,7 @@ func (p *Provider) createLaunchTemplate(ctx context.Context, params *parameters. StorageProfile: params.StorageProfile, } - if p.provisionMode == options.ProvisionModeBootstrappingClient { + if p.provisionMode == consts.ProvisionModeBootstrappingClient { customData, cse, err := params.AgentBakerNodeBootstrapping.GetCustomDataAndCSE(ctx) if err != nil { return nil, err From a57bb00cb273ffd88ad79c99f05a10631bbb73fb Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Sun, 20 Oct 2024 11:58:33 -0700 Subject: [PATCH 15/16] chore: added missing fullstops in other env descriptions --- pkg/operator/options/options.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/operator/options/options.go b/pkg/operator/options/options.go index d417b29dc..1a57ca837 100644 --- a/pkg/operator/options/options.go +++ b/pkg/operator/options/options.go @@ -86,12 +86,12 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) { fs.StringVar(&o.KubeletClientTLSBootstrapToken, "kubelet-bootstrap-token", env.WithDefaultString("KUBELET_BOOTSTRAP_TOKEN", ""), "[REQUIRED] The bootstrap token for new nodes to join the cluster.") fs.StringVar(&o.SSHPublicKey, "ssh-public-key", env.WithDefaultString("SSH_PUBLIC_KEY", ""), "[REQUIRED] VM SSH public key.") fs.StringVar(&o.NetworkPlugin, "network-plugin", env.WithDefaultString("NETWORK_PLUGIN", consts.NetworkPluginAzure), "The network plugin used by the cluster.") - fs.StringVar(&o.NetworkPluginMode, "network-plugin-mode", env.WithDefaultString("NETWORK_PLUGIN_MODE", consts.NetworkPluginModeOverlay), "network plugin mode of the cluster") + fs.StringVar(&o.NetworkPluginMode, "network-plugin-mode", env.WithDefaultString("NETWORK_PLUGIN_MODE", consts.NetworkPluginModeOverlay), "network plugin mode of the cluster.") fs.StringVar(&o.NetworkPolicy, "network-policy", env.WithDefaultString("NETWORK_POLICY", ""), "The network policy used by the cluster.") fs.StringVar(&o.NetworkDataplane, "network-dataplane", env.WithDefaultString("NETWORK_DATAPLANE", "cilium"), "The network dataplane used by the cluster.") - fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR") + fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR.") fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.") - fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live") + fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live.") fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", consts.ProvisionModeAKSSelfContained), "[UNSUPPORTED] The provision mode for the cluster.") fs.StringVar(&o.NodeBootstrappingServerURL, "nodebootstrapping-server-url", env.WithDefaultString("NODEBOOTSTRAPPING_SERVER_URL", ""), "[UNSUPPORTED] The url for the node bootstrapping provider server.") } From aadbe7b9d0ca80490e4c8c35777aec8b4540ceec Mon Sep 17 00:00:00 2001 From: Robin Deeboonchai Date: Sun, 20 Oct 2024 12:13:43 -0700 Subject: [PATCH 16/16] chore: rename bootstrapping types to scriptless and customscripts to align with AgentBaker --- pkg/consts/consts.go | 2 +- pkg/operator/options/options.go | 2 +- pkg/operator/options/options_validation.go | 2 +- pkg/providers/imagefamily/azlinux.go | 8 ++++---- .../customscriptsbootstrap.go} | 3 +-- .../provisionclientbootstrap.go | 4 ++-- .../provisionclientbootstrap_test.go | 2 +- pkg/providers/imagefamily/resolver.go | 12 ++++++------ pkg/providers/imagefamily/ubuntu_2204.go | 8 ++++---- pkg/providers/instance/instance.go | 6 +++--- pkg/providers/launchtemplate/launchtemplate.go | 16 ++++++++-------- pkg/providers/launchtemplate/parameters/types.go | 12 ++++++------ 12 files changed, 38 insertions(+), 39 deletions(-) rename pkg/providers/imagefamily/{agentbakerbootstrap/agentbakerbootstrap.go => customscriptsbootstrap/customscriptsbootstrap.go} (90%) rename pkg/providers/imagefamily/{agentbakerbootstrap => customscriptsbootstrap}/provisionclientbootstrap.go (99%) rename pkg/providers/imagefamily/{agentbakerbootstrap => customscriptsbootstrap}/provisionclientbootstrap_test.go (98%) diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index 37ddebe2f..b64270faf 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -29,6 +29,6 @@ const ( DefaultKubernetesMaxPods = 250 - ProvisionModeAKSSelfContained = "aksselfcontained" + ProvisionModeAKSScriptless = "aksscriptless" ProvisionModeBootstrappingClient = "bootstrappingclient" ) diff --git a/pkg/operator/options/options.go b/pkg/operator/options/options.go index 1a57ca837..aa2102c92 100644 --- a/pkg/operator/options/options.go +++ b/pkg/operator/options/options.go @@ -92,7 +92,7 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) { fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR.") fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.") fs.StringVar(&o.NodeResourceGroup, "node-resource-group", env.WithDefaultString("AZURE_NODE_RESOURCE_GROUP", ""), "[REQUIRED] the resource group created and managed by AKS where the nodes live.") - fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", consts.ProvisionModeAKSSelfContained), "[UNSUPPORTED] The provision mode for the cluster.") + fs.StringVar(&o.ProvisionMode, "provision-mode", env.WithDefaultString("PROVISION_MODE", consts.ProvisionModeAKSScriptless), "[UNSUPPORTED] The provision mode for the cluster.") fs.StringVar(&o.NodeBootstrappingServerURL, "nodebootstrapping-server-url", env.WithDefaultString("NODEBOOTSTRAPPING_SERVER_URL", ""), "[UNSUPPORTED] The url for the node bootstrapping provider server.") } diff --git a/pkg/operator/options/options_validation.go b/pkg/operator/options/options_validation.go index cbcc993e2..63cc14e0d 100644 --- a/pkg/operator/options/options_validation.go +++ b/pkg/operator/options/options_validation.go @@ -85,7 +85,7 @@ func (o Options) validateVMMemoryOverheadPercent() error { } func (o Options) validateProvisionMode() error { - if o.ProvisionMode != consts.ProvisionModeAKSSelfContained && o.ProvisionMode != consts.ProvisionModeBootstrappingClient { + if o.ProvisionMode != consts.ProvisionModeAKSScriptless && o.ProvisionMode != consts.ProvisionModeBootstrappingClient { return fmt.Errorf("provision-mode is invalid: %s", o.ProvisionMode) } if o.ProvisionMode == consts.ProvisionModeBootstrappingClient { diff --git a/pkg/providers/imagefamily/azlinux.go b/pkg/providers/imagefamily/azlinux.go index b213819f2..34af28143 100644 --- a/pkg/providers/imagefamily/azlinux.go +++ b/pkg/providers/imagefamily/azlinux.go @@ -20,8 +20,8 @@ import ( v1 "k8s.io/api/core/v1" "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" - "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/customscriptsbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" @@ -77,7 +77,7 @@ func (u AzureLinux) DefaultImages() []DefaultImageOutput { } // UserData returns the default userdata script for the image Family -func (u AzureLinux) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u AzureLinux) ScriptlessCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, @@ -108,8 +108,8 @@ func (u AzureLinux) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletCo } // UserData returns the default userdata script for the image Family -func (u AzureLinux) AgentBakerNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) agentbakerbootstrap.Bootstrapper { - return agentbakerbootstrap.ProvisionClientBootstrap{ +func (u AzureLinux) CustomScriptsNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) customscriptsbootstrap.Bootstrapper { + return customscriptsbootstrap.ProvisionClientBootstrap{ ClusterName: u.Options.ClusterName, KubeletConfig: kubeletConfig, Taints: taints, diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go b/pkg/providers/imagefamily/customscriptsbootstrap/customscriptsbootstrap.go similarity index 90% rename from pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go rename to pkg/providers/imagefamily/customscriptsbootstrap/customscriptsbootstrap.go index 3facfa21c..f6e411173 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/agentbakerbootstrap.go +++ b/pkg/providers/imagefamily/customscriptsbootstrap/customscriptsbootstrap.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package agentbakerbootstrap +package customscriptsbootstrap import ( "context" @@ -23,7 +23,6 @@ import ( // Bootstrapper can be implemented to generate a bootstrap script // that uses the params from the Bootstrap type for a specific // bootstrapping method. -// The only one implemented right now is AKS bootstrap script type Bootstrapper interface { GetCustomDataAndCSE(ctx context.Context) (string, string, error) } diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go b/pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap.go similarity index 99% rename from pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go rename to pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap.go index bba3b3fbe..84ae0bd0c 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap.go +++ b/pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package agentbakerbootstrap +package customscriptsbootstrap import ( "context" @@ -63,7 +63,7 @@ type ProvisionClientBootstrap struct { ImageFamily string } -var _ Bootstrapper = (*ProvisionClientBootstrap)(nil) // assert ProvisionClientBootstrap implements AgentBakerBootstrapper +var _ Bootstrapper = (*ProvisionClientBootstrap)(nil) // assert ProvisionClientBootstrap implements customscriptsbootstrapper func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (string, string, error) { if p.IsWindows { diff --git a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go b/pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap_test.go similarity index 98% rename from pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go rename to pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap_test.go index 8e0cd79d7..66c8bc092 100644 --- a/pkg/providers/imagefamily/agentbakerbootstrap/provisionclientbootstrap_test.go +++ b/pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package agentbakerbootstrap +package customscriptsbootstrap import ( "fmt" diff --git a/pkg/providers/imagefamily/resolver.go b/pkg/providers/imagefamily/resolver.go index cad6f113f..f03602391 100644 --- a/pkg/providers/imagefamily/resolver.go +++ b/pkg/providers/imagefamily/resolver.go @@ -27,8 +27,8 @@ import ( "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" "github.com/Azure/karpenter-provider-azure/pkg/consts" "github.com/Azure/karpenter-provider-azure/pkg/metrics" - "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/customscriptsbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/instancetype" template "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" "github.com/samber/lo" @@ -44,14 +44,14 @@ type Resolver struct { // ImageFamily can be implemented to override the default logic for generating dynamic launch template parameters type ImageFamily interface { - SelfContainedCustomData( + ScriptlessCustomData( kubeletConfig *corev1beta1.KubeletConfiguration, taints []core.Taint, labels map[string]string, caBundle *string, instanceType *cloudprovider.InstanceType, ) bootstrap.Bootstrapper - AgentBakerNodeBootstrapping( + CustomScriptsNodeBootstrapping( kubeletConfig *corev1beta1.KubeletConfiguration, taints []core.Taint, startupTaints []core.Taint, @@ -59,7 +59,7 @@ type ImageFamily interface { instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string, - ) agentbakerbootstrap.Bootstrapper + ) customscriptsbootstrap.Bootstrapper Name() string // DefaultImages returns a list of default CommunityImage definitions for this ImageFamily. // Our Image Selection logic relies on the ordering of the default images to be ordered from most preferred to least, then we will select the latest image version available for that CommunityImage definition. @@ -93,14 +93,14 @@ func (r Resolver) Resolve(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, template := &template.Parameters{ StaticParameters: staticParameters, - SelfContainedCustomData: imageFamily.SelfContainedCustomData( + ScriptlessCustomData: imageFamily.ScriptlessCustomData( prepareKubeletConfiguration(instanceType, nodeClaim), append(nodeClaim.Spec.Taints, nodeClaim.Spec.StartupTaints...), staticParameters.Labels, staticParameters.CABundle, instanceType, ), - AgentBakerNodeBootstrapping: imageFamily.AgentBakerNodeBootstrapping( + CustomScriptsNodeBootstrapping: imageFamily.CustomScriptsNodeBootstrapping( prepareKubeletConfiguration(instanceType, nodeClaim), nodeClaim.Spec.Taints, nodeClaim.Spec.StartupTaints, diff --git a/pkg/providers/imagefamily/ubuntu_2204.go b/pkg/providers/imagefamily/ubuntu_2204.go index fb58a35a0..1023bbfdf 100644 --- a/pkg/providers/imagefamily/ubuntu_2204.go +++ b/pkg/providers/imagefamily/ubuntu_2204.go @@ -20,8 +20,8 @@ import ( v1 "k8s.io/api/core/v1" "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2" - "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/customscriptsbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/launchtemplate/parameters" corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" @@ -77,7 +77,7 @@ func (u Ubuntu2204) DefaultImages() []DefaultImageOutput { } // UserData returns the default userdata script for the image Family -func (u Ubuntu2204) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { +func (u Ubuntu2204) ScriptlessCustomData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ *cloudprovider.InstanceType) bootstrap.Bootstrapper { return bootstrap.AKS{ Options: bootstrap.Options{ ClusterName: u.Options.ClusterName, @@ -107,8 +107,8 @@ func (u Ubuntu2204) SelfContainedCustomData(kubeletConfig *corev1beta1.KubeletCo } // UserData returns the default userdata script for the image Family -func (u Ubuntu2204) AgentBakerNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) agentbakerbootstrap.Bootstrapper { - return agentbakerbootstrap.ProvisionClientBootstrap{ +func (u Ubuntu2204) CustomScriptsNodeBootstrapping(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, startupTaints []v1.Taint, labels map[string]string, instanceType *cloudprovider.InstanceType, imageDistro string, storageProfile string) customscriptsbootstrap.Bootstrapper { + return customscriptsbootstrap.ProvisionClientBootstrap{ ClusterName: u.Options.ClusterName, KubeletConfig: kubeletConfig, Taints: taints, diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index 89c69406e..58060f3c0 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -367,9 +367,9 @@ func newVMObject( setVMPropertiesBillingProfile(vm.Properties, capacityType) if provisionMode == consts.ProvisionModeBootstrappingClient { - vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.AgentBakerCustomData) + vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.CustomScriptsCustomData) } else { - vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.SelfContainedCustomData) + vm.Properties.OSProfile.CustomData = lo.ToPtr(launchTemplate.ScriptlessCustomData) } return vm @@ -462,7 +462,7 @@ func (p *Provider) launchInstance( } if p.provisionMode == consts.ProvisionModeBootstrappingClient { - err = p.createCSExtension(ctx, resourceName, launchTemplate.AgentBakerCSE, launchTemplate.IsWindows) + err = p.createCSExtension(ctx, resourceName, launchTemplate.CustomScriptsCSE, launchTemplate.IsWindows) if err != nil { // This should fall back to cleanupAzureResources return nil, nil, err diff --git a/pkg/providers/launchtemplate/launchtemplate.go b/pkg/providers/launchtemplate/launchtemplate.go index 5545f02f0..41230a92c 100644 --- a/pkg/providers/launchtemplate/launchtemplate.go +++ b/pkg/providers/launchtemplate/launchtemplate.go @@ -45,12 +45,12 @@ const ( ) type Template struct { - SelfContainedCustomData string + ScriptlessCustomData string ImageID string SubnetID string Tags map[string]*string - AgentBakerCustomData string - AgentBakerCSE string + CustomScriptsCustomData string + CustomScriptsCSE string IsWindows bool StorageProfile string } @@ -180,19 +180,19 @@ func (p *Provider) createLaunchTemplate(ctx context.Context, params *parameters. } if p.provisionMode == consts.ProvisionModeBootstrappingClient { - customData, cse, err := params.AgentBakerNodeBootstrapping.GetCustomDataAndCSE(ctx) + customData, cse, err := params.CustomScriptsNodeBootstrapping.GetCustomDataAndCSE(ctx) if err != nil { return nil, err } - template.AgentBakerCustomData = customData - template.AgentBakerCSE = cse + template.CustomScriptsCustomData = customData + template.CustomScriptsCSE = cse } else { // render user data - userData, err := params.SelfContainedCustomData.Script() + userData, err := params.ScriptlessCustomData.Script() if err != nil { return nil, err } - template.SelfContainedCustomData = userData + template.ScriptlessCustomData = userData } return template, nil diff --git a/pkg/providers/launchtemplate/parameters/types.go b/pkg/providers/launchtemplate/parameters/types.go index 8ef609eee..8f2bda9f4 100644 --- a/pkg/providers/launchtemplate/parameters/types.go +++ b/pkg/providers/launchtemplate/parameters/types.go @@ -17,8 +17,8 @@ limitations under the License. package parameters import ( - "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/agentbakerbootstrap" "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/bootstrap" + "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/customscriptsbootstrap" ) // StaticParameters define the static launch template parameters @@ -51,9 +51,9 @@ type StaticParameters struct { // Parameters adds the dynamically generated launch template parameters type Parameters struct { *StaticParameters - SelfContainedCustomData bootstrap.Bootstrapper - AgentBakerNodeBootstrapping agentbakerbootstrap.Bootstrapper - ImageID string - StorageProfile string - IsWindows bool + ScriptlessCustomData bootstrap.Bootstrapper + CustomScriptsNodeBootstrapping customscriptsbootstrap.Bootstrapper + ImageID string + StorageProfile string + IsWindows bool }