Skip to content

Commit

Permalink
remove references to m3
Browse files Browse the repository at this point in the history
  • Loading branch information
dvaldivia committed Jul 8, 2020
1 parent b8a849b commit 38780d5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func GetK8sConfig(token string) *rest.Config {
// if m3 is running inside k8s by default he will have access to the ca cert from the k8s local authority
// if console is running inside k8s by default he will have access to the ca cert from the k8s local authority
const (
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
)
Expand Down
16 changes: 8 additions & 8 deletions cluster/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ var (
)

func GetK8sAPIServer() string {
// if m3 is running inside a k8s pod KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT will contain the k8s api server apiServerAddress
// if m3 is not running inside k8s by default will look for the k8s api server on localhost:8001 (kubectl proxy)
// if console is running inside a k8s pod KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT will contain the k8s api server apiServerAddress
// if console is not running inside k8s by default will look for the k8s api server on localhost:8001 (kubectl proxy)
// NOTE: using kubectl proxy is for local development only, since every request send to localhost:8001 will bypass service account authentication
// more info here: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#directly-accessing-the-rest-api
// you can override this using M3_K8S_API_SERVER, ie use the k8s cluster from `kubectl config view`
// you can override this using MCS_K8S_API_SERVER, ie use the k8s cluster from `kubectl config view`
host, port := env.Get("KUBERNETES_SERVICE_HOST", ""), env.Get("KUBERNETES_SERVICE_PORT", "")
apiServerAddress := "http://localhost:8001"
if host != "" && port != "" {
apiServerAddress = "https://" + net.JoinHostPort(host, port)
}
return env.Get(M3K8sAPIServer, apiServerAddress)
return env.Get(McsK8sAPIServer, apiServerAddress)
}

// getK8sAPIServerInsecure allow to tell the k8s client to skip TLS certificate verification, ie: when connecting to a k8s cluster
// that uses certificate not trusted by your machine
func getK8sAPIServerInsecure() bool {
return strings.ToLower(env.Get(m3k8SAPIServerInsecure, "off")) == "on"
return strings.ToLower(env.Get(McsK8SAPIServerInsecure, "off")) == "on"
}

// GetNsFromFile assumes console is running inside a k8s pod and extract the current namespace from the
Expand All @@ -69,7 +69,7 @@ var namespace = GetNsFromFile()

// Returns the namespace in which the controller is installed
func GetNs() string {
return env.Get(M3Namespace, namespace)
return env.Get(McsNamespace, namespace)
}

// getLatestMinIOImage returns the latest docker image for MinIO if found on the internet
Expand Down Expand Up @@ -106,7 +106,7 @@ var latestMinIOImage, errLatestMinIOImage = getLatestMinIOImage(
// a preferred image to be used (configured via ENVIRONMENT VARIABLES) GetMinioImage will return that
// if not, GetMinioImage will try to obtain the image URL for the latest version of MinIO and return that
func GetMinioImage() (*string, error) {
image := strings.TrimSpace(env.Get(M3MinioImage, ""))
image := strings.TrimSpace(env.Get(McsMinioImage, ""))
// if there is a preferred image configured by the user we'll always return that
if image != "" {
return &image, nil
Expand Down Expand Up @@ -156,7 +156,7 @@ func getLatestMCImage() (*string, error) {
var latestMCImage, errLatestMCImage = getLatestMCImage()

func GetMCImage() (*string, error) {
image := strings.TrimSpace(env.Get(M3MCImage, ""))
image := strings.TrimSpace(env.Get(McsMCImage, ""))
// if there is a preferred image configured by the user we'll always return that
if image != "" {
return &image, nil
Expand Down
10 changes: 5 additions & 5 deletions cluster/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package cluster

const (
M3K8sAPIServer = "M3_K8S_API_SERVER"
m3k8SAPIServerInsecure = "M3_K8S_API_SERVER_INSECURE"
M3MinioImage = "M3_MINIO_IMAGE"
M3MCImage = "M3_MC_IMAGE"
M3Namespace = "M3_NAMESPACE"
McsK8sAPIServer = "MCS_K8S_API_SERVER"
McsK8SAPIServerInsecure = "MCS_K8S_API_SERVER_INSECURE"
McsMinioImage = "MCS_MINIO_IMAGE"
McsMCImage = "MCS_MC_IMAGE"
McsNamespace = "MCS_NAMESPACE"
)
2 changes: 1 addition & 1 deletion restapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,5 @@ func getSecureExpectCTHeader() string {
// getTenantMemorySize Memory size value to be used when generating the
// MinioInstance request
func getTenantMemorySize() string {
return env.Get(M3TenantMemorySize, defaultTenantMemorySize)
return env.Get(McsTenantMemorySize, defaultTenantMemorySize)
}
2 changes: 1 addition & 1 deletion restapi/configure_mcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func configureAPI(api *operations.McsAPI) http.Handler {
// Register admin Service Account Handlers
registerServiceAccountsHandlers(api)

//m3
// Operator Console
// Register tenant handlers
registerTenantHandlers(api)
// Register ResourceQuota handlers
Expand Down
10 changes: 2 additions & 8 deletions restapi/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
package restapi

const (
// consts for common configuration
M3Version = `0.1.0`
M3Hostname = "M3_HOSTNAME"
M3Port = "M3_PORT"
M3TLSHostname = "M3_TLS_HOSTNAME"
M3TLSPort = "M3_TLS_PORT"
// M3TenantMemorySize Memory size to be used when creating MinioInstance request
M3TenantMemorySize = "M3_TENANT_MEMORY_SIZE"
// McsTenantMemorySize Memory size to be used when creating MinioInstance request
McsTenantMemorySize = "MCS_TENANT_MEMORY_SIZE"
)
12 changes: 6 additions & 6 deletions restapi/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ func gkeIntegration(clientset *kubernetes.Clientset, tenantName string, namespac
return err
}
// udpate ingress with this new service
m3Ingress, err := clientset.ExtensionsV1beta1().Ingresses(namespace).Get(context.Background(), "console-ingress", metav1.GetOptions{})
consoleIngress, err := clientset.ExtensionsV1beta1().Ingresses(namespace).Get(context.Background(), "console-ingress", metav1.GetOptions{})
if err != nil {
return err
}

certsInIngress := m3Ingress.ObjectMeta.Annotations["networking.gke.io/managed-certificates"]
certsInIngress := consoleIngress.ObjectMeta.Annotations["networking.gke.io/managed-certificates"]
allCerts := strings.Split(certsInIngress, ",")
allCerts = append(allCerts, manCertName)
m3Ingress.ObjectMeta.Annotations["networking.gke.io/managed-certificates"] = strings.Join(allCerts, ",")
consoleIngress.ObjectMeta.Annotations["networking.gke.io/managed-certificates"] = strings.Join(allCerts, ",")

tenantNodePortIoS := intstr.IntOrString{
Type: intstr.Int,
Expand All @@ -190,7 +190,7 @@ func gkeIntegration(clientset *kubernetes.Clientset, tenantName string, namespac
IntVal: int32(tenantMcsNodePort),
}

m3Ingress.Spec.Rules = append(m3Ingress.Spec.Rules, extensionsBeta1.IngressRule{
consoleIngress.Spec.Rules = append(consoleIngress.Spec.Rules, extensionsBeta1.IngressRule{
Host: tenantDomain,
IngressRuleValue: extensionsBeta1.IngressRuleValue{
HTTP: &extensionsBeta1.HTTPIngressRuleValue{
Expand All @@ -205,7 +205,7 @@ func gkeIntegration(clientset *kubernetes.Clientset, tenantName string, namespac
},
},
})
m3Ingress.Spec.Rules = append(m3Ingress.Spec.Rules, extensionsBeta1.IngressRule{
consoleIngress.Spec.Rules = append(consoleIngress.Spec.Rules, extensionsBeta1.IngressRule{
Host: tenantMcsDomain,
IngressRuleValue: extensionsBeta1.IngressRuleValue{
HTTP: &extensionsBeta1.HTTPIngressRuleValue{
Expand All @@ -221,7 +221,7 @@ func gkeIntegration(clientset *kubernetes.Clientset, tenantName string, namespac
},
})

_, err = clientset.ExtensionsV1beta1().Ingresses(namespace).Update(context.Background(), m3Ingress, metav1.UpdateOptions{})
_, err = clientset.ExtensionsV1beta1().Ingresses(namespace).Update(context.Background(), consoleIngress, metav1.UpdateOptions{})
if err != nil {
return err
}
Expand Down

0 comments on commit 38780d5

Please sign in to comment.