nodeport for operator login - cniackz/public GitHub Wiki

Objective:

To use NodePort for Operator Login

Steps:

  1. Delete previous cluster
kind delete cluster
  1. Save this file as kind-config.yaml:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
  apiServerAddress: "127.0.0.1"
  apiServerPort: 6443
nodes:
  - role: control-plane
    extraPortMappings:
    - containerPort: 30080
      hostPort: 30080
      listenAddress: "127.0.0.1"
      protocol: TCP
  - role: worker
    extraPortMappings:
    - containerPort: 30081
      hostPort: 30081
      listenAddress: "127.0.0.1"
      protocol: TCP
  - role: worker
    extraPortMappings:
    - containerPort: 30082
      hostPort: 30082
      listenAddress: "127.0.0.1"
      protocol: TCP
  - role: worker
    extraPortMappings:
    - containerPort: 30083
      hostPort: 30083
      listenAddress: "127.0.0.1"
      protocol: TCP
  - role: worker
    extraPortMappings:
    - containerPort: 30084
      hostPort: 30084
      listenAddress: "127.0.0.1"
      protocol: TCP
  1. Create cluster
kind create cluster --config kind-config.yaml
  1. Install operator:
kubectl apply -k github.com/minio/operator/
  1. Change console service:
  • spec.type is NodePort
  • spec.ports[0].nodePort is 30080
spec:
  ports:
    - name: http
      protocol: TCP
      port: 9090
      targetPort: 9090
      nodePort: 30080 <-------- To reach console in this port in your computer
    - name: https
      protocol: TCP
      port: 9443
      targetPort: 9443
      nodePort: 30965
  selector:
    app: console
  clusterIP: 10.96.41.107
  clusterIPs:
    - 10.96.41.107
  type: NodePort
  1. Open Browser and login:
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: console-sa-secret
  namespace: minio-operator
  annotations:
    kubernetes.io/service-account.name: console-sa
type: kubernetes.io/service-account-token
EOF


SA_TOKEN=$(kubectl -n minio-operator  get secret console-sa-secret -o jsonpath="{.data.token}" | base64 --decode)
echo $SA_TOKEN