Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] list clusters from all namespaces #978

Closed
softshipper opened this issue May 17, 2020 · 5 comments · Fixed by #1082
Closed

[UI] list clusters from all namespaces #978

softshipper opened this issue May 17, 2020 · 5 comments · Fixed by #1082
Labels

Comments

@softshipper
Copy link

Hi all

I have installed https://github.com/zalando/postgres-operator on my K8S cluster on namespace postgres and have created a database as follows:

kind: "postgresql"
apiVersion: "acid.zalan.do/v1"

metadata:
  name: "acid-databaker-db"
  namespace: "dev"
  labels:
    team: acid

spec:
  teamId: "acid"
  postgresql:
    version: "12"
  numberOfInstances: 2
  volume:
    size: "5Gi"
  users:
    admin: []
  databases:
    keycloak: admin
  allowedSourceRanges:
    # IP ranges to access your cluster go here

  resources:
    requests:
      cpu: 100m
      memory: 100Mi
    limits:
      cpu: 500m
      memory: 500Mi 

As you can see, the database has been created in namespace: "dev".
When I starts the UI:
kubectl port-forward -n postgres "$(kubectl get pod -l app.kubernetes.io/name=postgres-operator-ui -n postgres --output='name')" 8081

I can not see the created cluster:

Screenshot from 2020-05-17 11-17-12

I have also set the current context to dev:
kubectl config set-context $(kubectl config current-context) --namespace=dev

What am I doing wrong?

Thanks

@FxKu
Copy link
Member

FxKu commented May 18, 2020

In the values.yaml for the UI change targetNamespace to "*".

You have to add double quotes in the deployment manifest template where the env variable is inserted. Then you will see clusters from all namespaces.

@FxKu FxKu changed the title Where is the created cluster? [UI] list clusters from all namespaces May 18, 2020
@FxKu FxKu added the question label May 18, 2020
@softshipper
Copy link
Author

Hi FxKu
Thanks for your response. I have changed to:
values.yaml:

envs:
  # IMPORTANT: While operator chart and UI chart are idendependent, this is the interface between
  # UI and operator API. Insert the service name of the operator API here!
  operatorApiUrl: "http://postgres-operator:8080"
  operatorClusterNameLabel: "cluster-name"
  resourcesVisible: "False"
  targetNamespace: "*"

and deployment.yaml:

          env:
            - name: "APP_URL"
              value: "http://localhost:8081"
            - name: "OPERATOR_API_URL"
              value: {{ .Values.envs.operatorApiUrl }}
            - name: "OPERATOR_CLUSTER_NAME_LABEL"
              value: {{ .Values.envs.operatorClusterNameLabel }}
            - name: "RESOURCES_VISIBLE"
              value: "{{ .Values.envs.resourcesVisible }}"
            - name: "TARGET_NAMESPACE"
              value: "{{ .Values.envs.targetNamespace }}"
            - name: "TEAMS"
              value: |-
                [
                  "acid"
                ]

After the start:

helm install postgres-operator-ui -n postgres ./charts/postgres-operator-ui
NAME: postgres-operator-ui
LAST DEPLOYED: Mon May 18 13:12:48 2020
NAMESPACE: postgres
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
To verify that postgres-operator has started, run:

  kubectl --namespace=postgres get pods -l "app.kubernetes.io/name=postgres-operator-ui"  

I've got:

kubectl --namespace=postgres get pods -l "app.kubernetes.io/name=postgres-operator-ui" -n postgres 
NAME                                    READY   STATUS             RESTARTS   AGE
postgres-operator-ui-6d9c99fbcd-rf6rt   0/1     CrashLoopBackOff   4          3m44s

Inside the container, it shows:


operator_ui.spiloutils INFO     Common Cluster Label: {"application":"spilo"}
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 936, in emit
    self.socket.send(msg)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 390, in send
    return _socket.socket.send(self._sock, data, flags)
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 857, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 307, in connect
    raise error(result, strerror(result))
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 939, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python3.6/logging/handlers.py", line 868, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 307, in connect
    raise error(result, strerror(result))
FileNotFoundError: [Errno 2] No such file or directory
Call stack:
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/operator_ui/__main__.py", line 1, in <module>
    from .main import main
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/operator_ui/main.py", line 42, in <module>
    from .spiloutils import (
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/operator_ui/spiloutils.py", line 24, in <module>
    logger.info("Common Cluster Label: {}".format(COMMON_CLUSTER_LABEL))
Message: 'Common Cluster Label: {"application":"spilo"}'
Arguments: ()
operator_ui.spiloutils INFO     Common Pooler Label: {"application":"db-connection-pooler"}
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 936, in emit
    self.socket.send(msg)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 390, in send
    return _socket.socket.send(self._sock, data, flags)
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 857, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 307, in connect
    raise error(result, strerror(result))
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/handlers.py", line 939, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python3.6/logging/handlers.py", line 868, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python3.6/site-packages/gevent/_socket3.py", line 307, in connect
    raise error(result, strerror(result))
FileNotFoundError: [Errno 2] No such file or directory
Call stack:
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/operator_ui/__main__.py", line 1, in <module>
    from .main import main
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/operator_ui/main.py", line 42, in <module>
    from .spiloutils import (
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/operator_ui/spiloutils.py", line 25, in <module>
    logger.info("Common Pooler Label: {}".format(COMMON_POOLER_LABEL))
Message: 'Common Pooler Label: {"application":"db-connection-pooler"}'
Arguments: ()
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/operator_ui/__main__.py", line 3, in <module>
    main()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/operator_ui/main.py", line 1039, in main
    basicConfig(stream=sys.stdout, level=(DEBUG if debug else INFO), format='%(asctime)s %(levelname)s: %(message)s',)
NameError: name 'sys' is not defined 

What am I doing wrong?

Thanks

@softshipper
Copy link
Author

Now it works. I executed the ui chart from https://github.com/zalando/postgres-operator.git, instead https://github.com/zalando/postgres-operator/releases/tag/v1.5.0.

Thanks

@abdennour
Copy link

abdennour commented Jun 19, 2020

@FxKu I understand that I've to go to templates/deployment.yaml and edit in order to make it work.
Really ?
So i went there and I replaced value: {{ .Values.envs.targetNamespace }} by value: "{{ .Values.envs.targetNamespace }}" .
And it works
Please fix this big issue. Charts are designed to be parametrizable from values and no other places.

Hint:

{{if eq .Values.envs.targetNamespace "default"}} ... {{else}} .... {{end}}

@rory-ye-nv
Copy link

still have the same error in master branch, what's the root cause for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants