Skip to content

Commit

Permalink
Using tls name from CR spec instead of enviornment varialble. (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja authored Sep 1, 2023
1 parent 2027770 commit ae2993f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions pkg/common-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
)

var (
myPodTLSEnabled = os.Getenv("MY_POD_TLS_ENABLED")
clusterName = os.Getenv("MY_POD_CLUSTER_NAME")
clusterName = os.Getenv("MY_POD_CLUSTER_NAME")
)

type InitParams struct {
Expand All @@ -31,6 +30,7 @@ type InitParams struct {
rackID string
nodeID string
workDir string
tlsName string
logger logr.Logger
}

Expand Down Expand Up @@ -88,6 +88,8 @@ func PopulateInitParams(ctx goctx.Context) (*InitParams, error) {
workDir := asdbv1.GetWorkDirectory(rack.AerospikeConfig)
volume := rack.Storage.GetVolumeForAerospikePath(workDir)

tlsName, _ := asdbv1.GetServiceTLSNameAndPort(aeroCluster.Spec.AerospikeConfig)

if volume != nil {
// Init container mounts all volumes by name. Update workdir to reflect that path.
// For example
Expand All @@ -110,6 +112,7 @@ func PopulateInitParams(ctx goctx.Context) (*InitParams, error) {
nodeID: nodeID,
workDir: workDir,
logger: logger,
tlsName: tlsName,
}

if err := initParams.setNetworkInfo(ctx); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/create-aerospike-conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (initp *InitParams) createAerospikeConf() error {
initp.networkInfo.customAlternateAccessNetworkIPs, confString)
}

if tlsEnabled, _ := strconv.ParseBool(myPodTLSEnabled); tlsEnabled {
if initp.tlsName != "" {
confString = initp.substituteEndpoint(
initp.networkInfo.networkPolicy.TLSAccessType, tlsAccess, initp.networkInfo.configureAccessIP,
initp.networkInfo.customTLSAccessNetworkIPs, confString)
Expand Down
7 changes: 3 additions & 4 deletions pkg/update_pod_status_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ func (initp *InitParams) getPVCUid(ctx context.Context, pod *corev1.Pod, volName
func (initp *InitParams) getNodeMetadata() *asdbv1.AerospikePodStatus {
podPort := initp.networkInfo.podPort

tlsEnabled, _ := strconv.ParseBool(myPodTLSEnabled)
if tlsEnabled {
if initp.tlsName != "" {
podPort = initp.networkInfo.podTLSPort
}

Expand All @@ -120,13 +119,13 @@ func (initp *InitParams) getNodeMetadata() *asdbv1.AerospikePodStatus {
Aerospike: asdbv1.AerospikeInstanceSummary{
ClusterName: clusterName,
NodeID: initp.nodeID,
TLSName: os.Getenv("MY_POD_TLS_NAME"),
TLSName: initp.tlsName,
},
}

if initp.isNodeNetwork() {
metadata.ServicePort = initp.networkInfo.mappedPort
if tlsEnabled {
if initp.tlsName != "" {
metadata.ServicePort = initp.networkInfo.mappedTLSPort
}
}
Expand Down

0 comments on commit ae2993f

Please sign in to comment.