Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ HealthProbePort: 8083

# Enable/Disable features.
FeatureFlags:
DeployNatsConnector: true
DeployConnector: true
DeployNeptune: false
SkipAstraRegistration: false
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ This guide provides instructions for installing the latest version of the Astra
clusterName: <CLUSTER_NAME>
skipTLSValidation: false # Should be set to false in production environments
tokenRef: astra-token
natsSyncClient:
cloudBridgeURL: <ASTRA_CONTROL_HOST_URL>
astraControlURL: <ASTRA_CONTROL_HOST_URL>
hostAliasIP: <ASTRA_HOST_ALIAS_IP_ADDRESS>
imageRegistry:
name: cr.astra.netapp.io/astra
Expand Down
20 changes: 10 additions & 10 deletions app/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func DefaultConfiguration() *MutableConfiguration {
WaitDurationForResource: 5 * time.Minute,
ErrorTimeout: 5,
FeatureFlags: featureFlags{
DeployNatsConnector: true,
DeployNeptune: true,
DeployConnector: true,
DeployNeptune: true,
},
}
}
Expand All @@ -95,8 +95,8 @@ func toImmutableConfig(config *MutableConfiguration) *ImmutableConfiguration {
waitDurationForResource: config.WaitDurationForResource,
errorTimeout: config.ErrorTimeout,
featureFlags: ImmutableFeatureFlags{
deployNatsConnector: config.FeatureFlags.DeployNatsConnector,
deployNeptune: config.FeatureFlags.DeployNeptune,
deployConnector: config.FeatureFlags.DeployConnector,
deployNeptune: config.FeatureFlags.DeployNeptune,
},
config: config,
}
Expand Down Expand Up @@ -142,17 +142,17 @@ func (i ImmutableConfiguration) FeatureFlags() ImmutableFeatureFlags {
}

type ImmutableFeatureFlags struct {
deployNatsConnector bool
deployNeptune bool
deployConnector bool
deployNeptune bool
}

type featureFlags struct {
DeployNatsConnector bool
DeployNeptune bool
DeployConnector bool
DeployNeptune bool
}

func (f ImmutableFeatureFlags) DeployNatsConnector() bool {
return f.deployNatsConnector
func (f ImmutableFeatureFlags) DeployConnector() bool {
return f.deployConnector
}

func (f ImmutableFeatureFlags) DeployNeptune() bool {
Expand Down
4 changes: 2 additions & 2 deletions app/conf/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func TestImmutableFeatureFlags(t *testing.T) {
// Initialize a test feature flag configuration
flags := conf.ImmutableFeatureFlags{}

if flags.DeployNatsConnector() != false {
t.Errorf("Expected true, got %v", flags.DeployNatsConnector())
if flags.DeployConnector() != false {
t.Errorf("Expected true, got %v", flags.DeployConnector())
}

if flags.DeployNeptune() != false {
Expand Down
28 changes: 15 additions & 13 deletions app/deployer/connector/astra_connect_natless.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co

connectorImage = fmt.Sprintf("%s/astra-connector:%s", imageRegistry, containerImage)
log.Info("Using AstraConnector image", "image", connectorImage)
replicaCount := int32(1)

if m.Spec.Astra.ClusterId == "" && m.Spec.Astra.ClusterName == "" {
err := fmt.Errorf("clusterID and clusterName both cannot be empty")
Expand All @@ -70,8 +71,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co
},
},
Spec: appsv1.DeploymentSpec{
// TODO remove option to set replica count in CRD. This should always only-ever be 1
Replicas: &m.Spec.AstraConnect.Replicas,
Replicas: &replicaCount,
Selector: &metav1.LabelSelector{
MatchLabels: ls,
},
Expand All @@ -88,17 +88,13 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co
Name: "LOG_LEVEL", // todo should this match what operator is
Value: "info",
},
{
Name: "NATS_DISABLED",
Value: "true",
},
{
Name: "API_TOKEN_SECRET_REF",
Value: m.Spec.Astra.TokenRef,
},
{
Name: "ASTRA_CONTROL_URL",
Value: m.Spec.NatsSyncClient.CloudBridgeURL,
Value: m.Spec.Astra.AstraControlURL,
},
{
Name: "ACCOUNT_ID",
Expand All @@ -114,7 +110,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co
},
{
Name: "HOST_ALIAS_IP",
Value: m.Spec.NatsSyncClient.HostAliasIP,
Value: m.Spec.Astra.HostAliasIP,
},
{
Name: "SKIP_TLS_VALIDATION",
Expand Down Expand Up @@ -198,17 +194,23 @@ func (d *AstraConnectDeployer) GetServiceObjects(m *v1.AstraConnector, ctx conte

// GetConfigMapObjects returns a ConfigMap object for Astra Connect
func (d *AstraConnectDeployer) GetConfigMapObjects(m *v1.AstraConnector, ctx context.Context) ([]client.Object, controllerutil.MutateFn, error) {
data := map[string]string{
"skip_tls_validation": strconv.FormatBool(m.Spec.Astra.SkipTLSValidation),
}

configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: m.Namespace,
Name: common.AstraConnectName,
},
Data: map[string]string{
//"nats_url": GetNatsURL(m),
"skip_tls_validation": strconv.FormatBool(m.Spec.Astra.SkipTLSValidation),
},
Data: data,
}

mutateFn := func() error {
configMap.Data = data
return nil
}
return []client.Object{configMap}, model.NonMutateFn, nil
return []client.Object{configMap}, mutateFn, nil
}

// GetServiceAccountObjects returns a ServiceAccount object for Astra Connect
Expand Down
4 changes: 1 addition & 3 deletions app/deployer/connector/astra_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestAstraConnectGetDeploymentObjects(t *testing.T) {

assert.Equal(t, 10, len(container.Env))
assert.Equal(t, "LOG_LEVEL", container.Env[0].Name)
assert.Equal(t, "NATS_DISABLED", container.Env[1].Name)
assert.Equal(t, "true", container.Env[1].Value)

assert.Equal(t, 1, len(deployment.Spec.Template.Spec.ImagePullSecrets))
Expand Down Expand Up @@ -116,8 +115,7 @@ func DummyAstraConnector() v1.AstraConnector {
Secret: "test-secret",
},
AstraConnect: v1.AstraConnect{
Image: "test-image",
Replicas: 1,
Image: "test-image",
},
AutoSupport: v1.AutoSupport{
Enrolled: true,
Expand Down
14 changes: 7 additions & 7 deletions app/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ type AstraConnector struct {

func GetAstraHostURL(astraConnector *v1.AstraConnector) string {
var astraHost string
if astraConnector.Spec.NatsSyncClient.CloudBridgeURL != "" {
astraHost = astraConnector.Spec.NatsSyncClient.CloudBridgeURL
if astraConnector.Spec.Astra.AstraControlURL != "" {
astraHost = astraConnector.Spec.Astra.AstraControlURL
astraHost = strings.TrimSuffix(astraHost, "/")
} else {
astraHost = common.NatsSyncClientDefaultCloudBridgeURL
astraHost = common.DefaultCloudAstraControlURL
}

return astraHost
Expand Down Expand Up @@ -160,8 +160,8 @@ func (c clusterRegisterUtil) SetHttpClient(disableTls bool, astraHost string) er
c.Log.WithValues("disableTls", disableTls).Info("TLS Validation Disabled! Not for use in production!")
}

if c.AstraConnector.Spec.NatsSyncClient.HostAliasIP != "" {
c.Log.WithValues("HostAliasIP", c.AstraConnector.Spec.NatsSyncClient.HostAliasIP).Info("Using the HostAlias IP")
if c.AstraConnector.Spec.Astra.HostAliasIP != "" {
c.Log.WithValues("HostAliasIP", c.AstraConnector.Spec.Astra.HostAliasIP).Info("Using the HostAlias IP")
cloudBridgeHost, err := c.getAstraHostFromURL(astraHost)
if err != nil {
return err
Expand All @@ -174,10 +174,10 @@ func (c clusterRegisterUtil) SetHttpClient(disableTls bool, astraHost string) er

http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
if addr == cloudBridgeHost+":443" {
addr = c.AstraConnector.Spec.NatsSyncClient.HostAliasIP + ":443"
addr = c.AstraConnector.Spec.Astra.HostAliasIP + ":443"
}
if addr == cloudBridgeHost+":80" {
addr = c.AstraConnector.Spec.NatsSyncClient.HostAliasIP + ":80"
addr = c.AstraConnector.Spec.Astra.HostAliasIP + ":80"
}
return dialer.DialContext(ctx, network, addr)
}
Expand Down
4 changes: 2 additions & 2 deletions app/register/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func createClusterRegister(astraConnectorInput AstraConnectorInput) (register.Cl
}

if astraConnectorInput.invalidHostDetails {
astraConnector.Spec.NatsSyncClient.CloudBridgeURL = testURL
astraConnector.Spec.NatsSyncClient.HostAliasIP = testIP
astraConnector.Spec.Astra.AstraControlURL = testURL
astraConnector.Spec.Astra.HostAliasIP = testIP
}

clusterRegisterUtil := register.NewClusterRegisterUtil(astraConnector, mockHttpClient, fakeClient, k8sUtil, log, context.Background())
Expand Down
21 changes: 1 addition & 20 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ package common
import (
_ "embed"
"strings"

"github.com/NetApp-Polaris/astra-connector-operator/app/conf"
)

const (
Expand All @@ -18,19 +16,14 @@ const (
AstraConnectName = "astraconnect"
AstraConnectorOperatorRepository = "netapp/astra-connector-operator"

NatsSyncClientDefaultImage = "natssync-client:2.2.202402012115"
NatsSyncClientDefaultCloudBridgeURL = "https://astra.netapp.io"
DefaultCloudAstraControlURL = "https://astra.netapp.io"

NeptuneName = "neptune-controller-manager"

NeptuneMetricServicePort = 8443
NeptuneMetricServiceProtocol = "TCP"
NeptuneReplicas = 1

ConnectorNeptuneCapability = "neptuneV1"
ConnectorV2Capability = "connectorV2" // V2 refers specifically to Arch 3.0 connector and beyond
ConnectorWatcherCapability = "watcherV1"

RbacProxyImage = "kube-rbac-proxy:v0.14.1"
)

Expand All @@ -55,15 +48,3 @@ var (
func GetNeptuneRepositories() []string {
return []string{"controller", "exechook", "resourcebackup", "resourcedelete", "resourcerestore", "resourcesummaryupload", "restic"}
}

func GetConnectorCapabilities() []string {
capabilities := []string{
ConnectorV2Capability,
ConnectorWatcherCapability,
}

if conf.Config.FeatureFlags().DeployNeptune() {
capabilities = append(capabilities, ConnectorNeptuneCapability)
}
return capabilities
}
47 changes: 12 additions & 35 deletions details/operator-sdk/api/v1/astraconnector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import (
type Astra struct {
// +kubebuilder:validation:Required
AccountId string `json:"accountId"`
// +kubebuilder:validation:Required
AstraControlURL string `json:"astraControlURL,omitempty"`
// +kubebuilder:validation:Optional
CloudId string `json:"cloudId"`
// +kubebuilder:validation:Optional
ClusterId string `json:"clusterId"`
// +kubebuilder:validation:Optional
ClusterName string `json:"clusterName,omitempty"`
// +kubebuilder:validation:Optional
HostAliasIP string `json:"hostAliasIP,omitempty"`
// +kubebuilder:validation:Optional
SkipTLSValidation bool `json:"skipTLSValidation,omitempty"`
TokenRef string `json:"tokenRef,omitempty"`
// +kubebuilder:validation:Optional
Expand All @@ -36,30 +40,10 @@ type AutoSupport struct {
URL string `json:"url,omitempty"`
}

type NatsSyncClient struct {
CloudBridgeURL string `json:"cloudBridgeURL,omitempty"`
// +kubebuilder:validation:Optional
Image string `json:"image,omitempty"`
// +kubebuilder:validation:Optional
HostAliasIP string `json:"hostAliasIP,omitempty"`
// +kubebuilder:default:=1
Replicas int32 `json:"replicas,omitempty"`
}

// +kubebuilder:validation:Optional

type Nats struct {
Image string `json:"image,omitempty"`
// +kubebuilder:default:=1
Replicas int32 `json:"replicas,omitempty"`
}

// +kubebuilder:validation:Optional

type AstraConnect struct {
Image string `json:"image,omitempty"`
// +kubebuilder:default:=1
Replicas int32 `json:"replicas,omitempty"`
Image string `json:"image,omitempty"`
ResourceRequirements corev1.ResourceRequirements `json:"resources,omitempty"`
}

Expand All @@ -73,12 +57,10 @@ type Neptune struct {

// AstraConnectorSpec defines the desired state of AstraConnector
type AstraConnectorSpec struct {
Astra Astra `json:"astra"`
NatsSyncClient NatsSyncClient `json:"natsSyncClient,omitempty"`
Nats Nats `json:"nats,omitempty"`
AstraConnect AstraConnect `json:"astraConnect,omitempty"`
Neptune Neptune `json:"neptune"`
ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"`
Astra Astra `json:"astra"`
AstraConnect AstraConnect `json:"astraConnect,omitempty"`
Neptune Neptune `json:"neptune"`
ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"`

// AutoSupport indicates willingness to participate in NetApp's proactive support application, NetApp Active IQ.
// An internet connection is required (port 442) and all support data is anonymized.
Expand All @@ -98,11 +80,6 @@ type AstraConnectorSpec struct {

// AstraConnectorStatus defines the observed state of AstraConnector
type AstraConnectorStatus struct {
NatsSyncClient NatsSyncClientStatus `json:"natsSyncClient"`
}

// NatsSyncClientStatus defines the observed state of NatsSyncClient
type NatsSyncClientStatus struct {
Registered string `json:"registered"` //todo cluster vs connector registered
AstraClusterId string `json:"astraClusterID,omitempty"`
Status string `json:"status"`
Expand All @@ -117,9 +94,9 @@ type ImageRegistry struct {

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Registered",type=string,JSONPath=`.status.natsSyncClient.registered`
//+kubebuilder:printcolumn:name="AstraClusterID",type=string,JSONPath=`.status.natsSyncClient.astraClusterID`
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.natsSyncClient.status`
//+kubebuilder:printcolumn:name="Registered",type=string,JSONPath=`.status.registered`
//+kubebuilder:printcolumn:name="AstraClusterID",type=string,JSONPath=`.status.astraClusterID`
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`

// AstraConnector is the Schema for the astraconnectors API
// +kubebuilder:subresource:status
Expand Down
Loading