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

Web terminal could not access in cluster resources #12899

Open
toschneck opened this issue Dec 12, 2023 · 6 comments
Open

Web terminal could not access in cluster resources #12899

toschneck opened this issue Dec 12, 2023 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@toschneck
Copy link
Member

What happened?

Currently when we create the web terminal container, a default network policy get applied, what drops in cluster traffic. So if I'm a developer and want quickly test my application for reachability via curl, I can't do this. In my opinion, the inside cluster traffic should be allowed. At least as a user I would expect it.
Cluster 'hardcore-hodgkin-cilium-ingress-test-ympkwbs4k9' in Project 'Tobi's Demo Project 🚀' 2023-12-12 11-51-34
Hubble UI 2023-12-12 11-52-21

Current applied network policy:
k get networkpolicies.networking.k8s.io -n kube-system webterminal-7557a12007cf6f5291f9863fa086c056 -o yaml

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  creationTimestamp: "2023-12-12T09:50:46Z"
  generation: 1
  name: webterminal-7557a12007cf6f5291f9863fa086c056
  namespace: kube-system
  resourceVersion: "13770"
  uid: 5331f58b-3e82-4a79-ba9d-a6cc2aba5e18
spec:
  egress:
  - ports:
    - port: 30051
      protocol: TCP
    to:
    - ipBlock:
        cidr: 35.241.213.147/32
  - ports:
    - port: 443
      protocol: TCP
    to:
    - ipBlock:
        cidr: 10.241.0.1/32
  - ports:
    - port: 53
      protocol: TCP
    - port: 53
      protocol: UDP
    to:
    - ipBlock:
        cidr: 0.0.0.0/0
  podSelector:
    matchLabels:
      app: webterminal
  policyTypes:
  - Ingress
  - Egress
status: {}

Expected behavior

Webterminal can access in cluster services / IPs (if no other network policy is applied)

How to reproduce the issue?

Creat a cluster with and create a webservice in a namespace, e.g. the echo application at run-2

ingress:
  enabled: true
  hosts:
    - paths:
        - /test
  pathType: Prefix

Start Webterminal => Curl to endpoint what you get:

k get svc -n echoserver
curl 10.241.X.X

If you do the same with e.g. another debug container it works:

kubectl run shell-4033 --timeout 600s --namespace default --rm -i --tty --image nicolaka/netshoot -- /bin/sh -c bash
#commands from above

How is your environment configured?

  • KKP version: 2.24.0
  • Shared or separate master/seed clusters?: combined

Provide your KKP manifest here (if applicable)

see https://github.com/kubermatic/sig-cs-infra/tree/main/lab.kubermatic.io/run-2.lab.kubermatic.io/settings

What cloud provider are you running on?

doesn't matter

What operating system are you running in your user cluster?

Ubuntu

Additional information

@toschneck toschneck added the kind/bug Categorizes issue or PR as related to a bug. label Dec 12, 2023
@embik
Copy link
Member

embik commented Dec 12, 2023

In my opinion, the inside cluster traffic should be allowed.

I disagree with this because it has security implications - the web terminal uses your OIDC identity and as such, you might just have access to specific namespaces via kubectl. If the web terminal is allowed traffic inside the cluster, users can access applications they don't have any permissions for.

We can maybe document how to create a NetworkPolicy that allows the web-terminal to access all (or specific) namespaces, but as a default this is potentially dangerous.

@toschneck
Copy link
Member Author

Sounds also like a good idea. Couldn't we may have a setting on the webterminal "enable cluster network access" from the KKP UI?
And if not enabled some hint text that may some access is blocked.

@kubermatic-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
After a furter 30 days, they will turn rotten.
Mark the issue as fresh with /remove-lifecycle stale.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kubermatic-bot kubermatic-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 13, 2024
@embik
Copy link
Member

embik commented Mar 15, 2024

/remove-lifecycle stale

@kubermatic-bot kubermatic-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 15, 2024
@mfahlandt
Copy link
Contributor

I think we should offer an option to at least allow egress traffic of the we terminal to make usage easier.
Otherwise you manually need to provide a network policy
E.g.
`
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-webterminal-internet
namespace: kube-system
spec:
podSelector:
matchLabels:
app: webterminal
policyTypes:

  • Egress
    egress:
  • {} # Allow all outbound traffic
    `

@toschneck
Copy link
Member Author

Agree, potential we could make a checkbox what enables the traffic

  • allow external traffic for terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants