Skip to content

Conversation

@cpretzer
Copy link
Contributor

Signed-off-by: Charles Pretzer charles@buoyant.io

This commit updates the Dockerfile to use the buster slim image debian:buster-20190910-slim

Copy link
Member

@siggy siggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for delayed review.

curious: is any change required around replacing iptables with iptables-legacy? i recall we hit a similar issue in the linkerd2 repo prior to moving proxy-init to this repo:
linkerd/linkerd2@14974e1#diff-99f27e036a094ea78b927b9c14cdb019R26-R29

@samlabs821
Copy link

debian buster uses nftables, which makes old rules incompatible

Dockerfile Outdated

## package runtime
FROM debian:stretch-20190812-slim
FROM debian:buster-20190910-slim
Copy link
Contributor

@joakimr-axis joakimr-axis Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be buster-20200514-slim in order to match the buster version used in the linkerd2 repo (https://github.com/linkerd/linkerd2/pull/4542/files)?

FROM debian:buster-20190910-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
iptables \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try adding

RUN update-alternatives --set iptables /usr/sbin/iptables-legacy \
    && update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

here to make current use of iptables work with buster.
(See linkerd/linkerd2#4567 for more info.)

@cpretzer cpretzer force-pushed the cpretzer/upgrade-base-to-buster branch from 6c3e0e5 to 69c4dad Compare June 17, 2020 00:50
@cpretzer
Copy link
Contributor Author

Tested with buster-20200514-slim and the init containers started with the expected output.

The dashboard and linkerd command line output (stat, tap, etc.) all look correct.

@alpeb
Copy link
Member

alpeb commented Jun 17, 2020

@cpretzer would you apply the iptables-legacy change suggested above? It's necessary for older k8s version, it seems.

@aliariff aliariff mentioned this pull request Jun 17, 2020
@cpretzer cpretzer mentioned this pull request Jun 18, 2020
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the last change proxy-init is failing for me:

$ k -n linkerd logs linkerd-controller-65cfb4b59f-mwfth linkerd-init
2020/06/18 10:15:04 Tracing this script execution as [1592475304]
2020/06/18 10:15:04 State of iptables rules before run:
2020/06/18 10:15:04 > iptables -t nat -vnL
2020/06/18 10:15:04 < Fatal: can't open lock file /run/xtables.lock: Read-only file system

@cpretzer
Copy link
Contributor Author

cpretzer commented Jun 19, 2020

@alpeb I found the same error testing on multiple kubernetes 1.14, 1.16, and 1.18.

I did some digging and found an issue in the Kubernetes repository which describes similar behavior. In that PR they address the issue by creating a hostPath to write /run/xtables.lock.

kind also uses hostPath.

I don't think we want to use hostPath, so I tested by adding an emptyDir volume to a deployment that I manually injected the proxy and proxy-init into and that enabled the container to start.

If I understand what iptables is doing, it's using xtables.lock to block other iptables processes from updating the current iptables rules until it completes its work. The problem with using emptyDir is that other init containers might expect to use this as well and using an emptyDir basically just lets the proxy-init container write to memory so that it can execute its commands, which basically isolates the xtables.lock for the pod. As a result, if another container/process is calling iptables this lock is meaningless.

I see that we use hostPath volumes for the cni-plugin, but adding a hostPath volume for proxy-init feels like a pretty significant change to the functionality.

What do you think is the right approach here? Is there another option that I've overlooked?

@cpretzer
Copy link
Contributor Author

Okay, I figured out what is going on: readOnlyRootFileSystem: true is set in the securityContext of the proxy-init container.

The integration tests haven't been updated to match the _proxy-init.tpl file, so they don't include readOnlyRootFileSystem among other settings.

Here is the output from the template in one of my service pods:

   initContainers:
...
        name: linkerd-init
...
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            add:
            - NET_ADMIN
            - NET_RAW
          privileged: false
          readOnlyRootFilesystem: true
          runAsNonRoot: false
          runAsUser: 0
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: FallbackToLogsOnError
...

And the iptablestest-lab.yaml has:

      initContainers:
      - name: linkerd-init
...
        securityContext:
          capabilities:
            add:
            - NET_ADMIN
          privileged: false
          runAsNonRoot: false
          runAsUser: 0
...

Using readOnlyRootFileSystem: true is the right thing to do, so we need to find a way to make /run writable, and I haven't thought of a better way other than the volumeMounts.

@alpeb
Copy link
Member

alpeb commented Jun 19, 2020

Thanks for the extra research @cpretzer 👍

From my understanding, readOnlyRootFileSystem refers to the container's ability to write to its top layer, which is still separate from the host's file system (I might be wrong here, my understanding of containers is limited). In which case if we set that to true, the pod won't fail but the locking mechanism will be moot, just like with the emptyDir option you mentioned.
Although it turns out readOnlyRootFileSystem: false is the solution others are relying on.

It also seems to me the only way to do this while keeping proper locking is to rely on hostPath. We'd have to update our PSP to allow that. We can use the PSP allowedHostPath rule to limit the path that is writable, but I'm seeing a scary warning in the docs saying that's easily abused.

I'm realizing we're not honoring that lock file in CNI given we're relying on the default readOnlyRootFileSystem: false there. Perhaps the easiest is to do the same here?

CC @grampelberg

@alpeb
Copy link
Member

alpeb commented Jun 19, 2020

As to why we're observing this behavior now even though we're still using iptables[-legacy], it's because we're also upgrading from iptables v1.6.0 to v1.8.2, and in v1.6.2 a change was introduced forcing the usage of that lock.

From this change:

Existing systems that depended on things working mostly correctly
even if there was no lock might be affected by this change

cpretzer added 3 commits July 7, 2020 12:11
Signed-off-by: Charles Pretzer <charles@buoyant.io>
Signed-off-by: Charles Pretzer <charles@buoyant.io>
Signed-off-by: Charles Pretzer <charles@buoyant.io>
@cpretzer cpretzer force-pushed the cpretzer/upgrade-base-to-buster branch from 8287761 to 507950a Compare July 7, 2020 19:16
@alpeb
Copy link
Member

alpeb commented Jul 8, 2020

@cpretzer This is running fine for me when I run the control plane in linkerd/linkerd2#4692 using the proxy-init image produced here. The integration test is hanging presumably because the volume changes from linkerd/linkerd2#4692 need to be applied here as well to the init-containers in the pods in iptablestest-lab.yaml in order to avoid the same /run/xtables.lock issue.

Signed-off-by: Charles Pretzer <charles@buoyant.io>
@cpretzer
Copy link
Contributor Author

thanks @alpeb working on this now

Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@cpretzer cpretzer requested a review from ihcsim July 14, 2020 20:12
Copy link
Contributor

@ihcsim ihcsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cpretzer cpretzer merged commit 378dfbb into master Jul 14, 2020
@cpretzer cpretzer deleted the cpretzer/upgrade-base-to-buster branch July 14, 2020 21:08
stevej pushed a commit that referenced this pull request Dec 3, 2022
Signed-off-by: Steve Jenson <stevej@buoyant.io>
stevej pushed a commit that referenced this pull request Dec 29, 2022
* modifying import paths and making a temporary copy of testutil/annotations.go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* removed testutil, dockerized cni installer tests now pass

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* moving internal to pkg/linkerd-, removing Dockerfile until fixed, changining imports, removing linkerd2 k8s client with client-go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* gofmt install-cni_test.go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* go mod updates

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding pkg to Docker image

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* updating dev from v32 to v35 for go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* moving back to old dev image

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* use dev:v32-go for go lint workflow

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixing linter complaints

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixing linter complaints

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #1

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #2

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #3

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #4

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #5

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #6

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* Replace pkg/ with internal/ (#148)

* Replace pkg/ with internal/

There's no need for a public library export. We can share code within
this repo via the `internal` directory.

* simplify package names

Signed-off-by: Oliver Gould <ver@buoyant.io>

* adding internal back. whoopsie

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* bumping dev go version

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* replace deprecated ioutil functions with io functions.

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* increasing timeout to help with linter issues, adding verbose

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* replace TODO with literals, wait for the linter to complain so we can give it the magic incantation to sleep now

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* more linter

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* gofmt

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* swap position of comment and argument as the linter has an opinion here, too

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* Update cni-plugin/main.go

Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>

* Update cni-plugin/main.go

Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>

* Update cni-plugin/main.go

Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>

* Update cni-plugin/main.go

Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>

* simplify lint call

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* removed unneeded abstraction

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* linter for cni-plugin and all go code

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* giving flags to go linter

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* run the test on the moved internal package

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding keys back for annotation lookup

Signed-off-by: Steve Jenson <stevej@buoyant.io>

Signed-off-by: Steve Jenson <stevej@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>
stevej pushed a commit that referenced this pull request Jan 18, 2023
* modifying import paths and making a temporary copy of testutil/annotations.go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* removed testutil, dockerized cni installer tests now pass

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* moving internal to pkg/linkerd-, removing Dockerfile until fixed, changining imports, removing linkerd2 k8s client with client-go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* gofmt install-cni_test.go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* go mod updates

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding pkg to Docker image

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* updating dev from v32 to v35 for go

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* moving back to old dev image

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* use dev:v32-go for go lint workflow

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixing linter complaints

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixing linter complaints

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #1

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #2

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #3

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #4

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #5

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* turning off noisy lint #6

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding in Dockerfile, just rules for building, and a workflow for testing the cni-plugin installer script

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* remember to setup docker

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* remember to setup docker-qemu

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* where is docker?

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* back to a named ubuntu version, removing devcontainer

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* we need just

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* WIP import of CNI plugin integration test environment. does not run due to image pull errors.

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* rewriting just rules to match new rules

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* bumping dev version, renaming smoke test

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* WIP for running smoke tests

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* go workflow fix

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* also rid ourselves of ioutil in this branch

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding a second, passing test

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* let's run the test in CI

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* name the test properly for CI to run it

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* made the installer integration tests more in-line with the other integration tests

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* cni-plugin integration test workflow

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* breaking up steps, renaming test

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* just

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* bringing changes from linkerd2 over

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* tests running within cni-plugin context

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* create service account and don't delete so we can inspect

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fix namespaces, use matei's k3d/k3s mountPaths in the hopes that CNI will run in our pod.

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* WIP for debugging why CNI won't run in my own pods despite everything looking normal

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* adding whitespace, fixing comment, removing unneeded variable

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixing some small things

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* improving Dockerfile, going back to edge for linkerd-cni

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* cleaned up Dockerfile

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* using --link for 50% size improvement

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* cleanup unusued functions, run network-validator before test suite

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* remove qemu setup, add comment about log level

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* add wiring to see cni-net-dir and check for kubeconfig

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* checking that linkerd-cni is the last plugin in the conflist

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* renaming smoke_test to flannel

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* rename files, update justfile

* name a test file _test so the test runner will run my test

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* renaming to flannel

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* remove hardcoded filename

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* clarified comment

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fixed merge conflict error

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fix log levels

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* fix a log level

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* run test on all files in ./cni-plugin

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* hcomment explaining why there's no ENTRYPOINT

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* use a map instead of an array for simplicity

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* abstract which integration test subdirectory gets used, add internal to ensure those packages are tested

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* go.yml is already running these tests are there no integration tests in there to run

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* breaking up a line

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* renaming SUBDIRECTORY to SCENARIO and renaming a run just target to flannel to signify that this is the rule to crib for other scenarios

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* better error handling of the cleanup() function, print more diagnostic information if linkerd-cni rollout fails

Signed-off-by: Steve Jenson <stevej@buoyant.io>

* add error handling for describe ds and logs

Signed-off-by: Steve Jenson <stevej@buoyant.io>

Signed-off-by: Steve Jenson <stevej@buoyant.io>
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

Successfully merging this pull request may close these issues.

7 participants