Skip to content

Commit 328133d

Browse files
authored
Fix Session validation for MCS Operator Mode (#191)
* Fix Session validation for MCS Operator Mode * Updated assets
1 parent 8a74b79 commit 328133d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+606
-396
lines changed

cluster/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func GetK8sConfig(token string) *rest.Config {
27-
// if m3 is running inside k8s by default he will have access to the ca cert from the k8s local authority
27+
// if console is running inside k8s by default he will have access to the ca cert from the k8s local authority
2828
const (
2929
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
3030
)
@@ -33,7 +33,7 @@ func GetK8sConfig(token string) *rest.Config {
3333
tlsClientConfig.CAFile = rootCAFile
3434
}
3535
config := &rest.Config{
36-
Host: getK8sAPIServer(),
36+
Host: GetK8sAPIServer(),
3737
TLSClientConfig: tlsClientConfig,
3838
APIPath: "/",
3939
BearerToken: token,

cluster/config.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@ var (
3434
errCantDetermineMCImage = errors.New("can't determine MC Image")
3535
)
3636

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

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

57-
// GetNsFromFile assumes mkube is running inside a k8s pod and extract the current namespace from the
57+
// GetNsFromFile assumes console is running inside a k8s pod and extract the current namespace from the
5858
// /var/run/secrets/kubernetes.io/serviceaccount/namespace file
5959
func GetNsFromFile() string {
6060
dat, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
@@ -64,12 +64,12 @@ func GetNsFromFile() string {
6464
return string(dat)
6565
}
6666

67-
// This operation will run only once at mkube startup
67+
// This operation will run only once at console startup
6868
var namespace = GetNsFromFile()
6969

7070
// Returns the namespace in which the controller is installed
7171
func GetNs() string {
72-
return env.Get(M3Namespace, namespace)
72+
return env.Get(McsNamespace, namespace)
7373
}
7474

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

158158
func GetMCImage() (*string, error) {
159-
image := strings.TrimSpace(env.Get(M3MCImage, ""))
159+
image := strings.TrimSpace(env.Get(McsMCImage, ""))
160160
// if there is a preferred image configured by the user we'll always return that
161161
if image != "" {
162162
return &image, nil

cluster/const.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package cluster
1818

1919
const (
20-
M3K8sAPIServer = "M3_K8S_API_SERVER"
21-
m3k8SAPIServerInsecure = "M3_K8S_API_SERVER_INSECURE"
22-
M3MinioImage = "M3_MINIO_IMAGE"
23-
M3MCImage = "M3_MC_IMAGE"
24-
M3Namespace = "M3_NAMESPACE"
20+
McsK8sAPIServer = "MCS_K8S_API_SERVER"
21+
McsK8SAPIServerInsecure = "MCS_K8S_API_SERVER_INSECURE"
22+
McsMinioImage = "MCS_MINIO_IMAGE"
23+
McsMCImage = "MCS_MC_IMAGE"
24+
McsNamespace = "MCS_NAMESPACE"
2525
)
File renamed without changes.
File renamed without changes.

k8s/console/base/mcs-deployment.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mcs
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: mcs
10+
template:
11+
metadata:
12+
labels:
13+
app: mcs
14+
spec:
15+
serviceAccountName: m3-sa
16+
containers:
17+
- name: mcs
18+
image: minio/mcs:latest
19+
imagePullPolicy: "IfNotPresent"
20+
args:
21+
- /mcs
22+
- server
23+
ports:
24+
- containerPort: 9090
25+
name: http
26+
- containerPort: 9433
27+
name: https
File renamed without changes.

0 commit comments

Comments
 (0)