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

What is the purpose of the sysctls image? #26

Open
airza opened this issue Apr 15, 2022 · 2 comments
Open

What is the purpose of the sysctls image? #26

airza opened this issue Apr 15, 2022 · 2 comments

Comments

@airza
Copy link

airza commented Apr 15, 2022

I'm trying to get this container to work on a k8s deployment and am a bit perplexed: the initContainer 'sysctls' is created and enables ipv4 routing but it doesn't seem to be accessed or used anywhere else. Can I remove this safely? It is quite possible that I don't understand how images are composed as I am new to k8s, but I don't understand its relationship to the wg container. Thanks for the image, by the way! I am slowly understanding what it's up to 8^)

@masipcat
Copy link
Owner

I think I need to improve the README :P The k8s example is not just how to deploy wireguard in a k8s cluster, it also contains the additional configuration to be able to communicate from outside the cluster to all the pods. That's the purpose of enabling ip routing and it can be done in a different container because it is a system-wide configuration (affects the entire k8s node).

I don't remember, but I guess I used the busybox image in the initContainer to avoid installing sysctl in the wireguard image. Anyway, now it seems that there is a better way to do it with k8s. Something like this should work as well (but I haven't tried):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wireguard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wireguard
  template:
    metadata:
      labels:
        app: wireguard
    spec:
      securityContext:
        sysctls:
        - name: net.ipv4.ip_forward
          value: "1"
        - name:  net.ipv4.conf.all.forwarding
          value: "1"
    containers:
        - name: wireguard
          image: masipcat/wireguard-go:latest
   ...

I hope this answers your questions :) If this works for you, feel free to open a PR to improve the readme with this change.

@airza
Copy link
Author

airza commented Apr 15, 2022 via email

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

No branches or pull requests

2 participants