forked from kubernetes/ingress-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jail/chroot nginx process inside controller container (kubernetes#8337)
* Initial work on chrooting nginx process * More improvements in chroot * Fix charts and some file locations * Fix symlink on non chrooted container * fix psp test * Add e2e tests to chroot image * Fix logger * Add internal logger in controller * Fix overlay for chrooted tests * Fix tests * fix boilerplates * Fix unittest to point to the right pid * Fix PR review
- Loading branch information
Showing
41 changed files
with
456 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,13 +100,14 @@ jobs: | |
REGISTRY: ingress-controller | ||
run: | | ||
echo "building images..." | ||
make clean-image build image | ||
make clean-image build image image-chroot | ||
make -C test/e2e-image image | ||
echo "creating images cache..." | ||
docker save \ | ||
nginx-ingress-controller:e2e \ | ||
ingress-controller/controller:1.0.0-dev \ | ||
ingress-controller/controller-chroot:1.0.0-dev \ | ||
| pigz > docker.tar.gz | ||
- name: cache | ||
|
@@ -250,6 +251,65 @@ jobs: | |
kind get kubeconfig > $HOME/.kube/kind-config-kind | ||
make kind-e2e-test | ||
kubernetes-chroot: | ||
name: Kubernetes chroot | ||
runs-on: ubuntu-latest | ||
needs: | ||
- changes | ||
- build | ||
if: | | ||
(needs.changes.outputs.go == 'true') | ||
strategy: | ||
matrix: | ||
k8s: [v1.21.10, v1.22.7, v1.23.4] | ||
|
||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: cache | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker.tar.gz | ||
|
||
- name: Create Kubernetes ${{ matrix.k8s }} cluster | ||
id: kind | ||
uses: engineerd/[email protected] | ||
with: | ||
version: v0.12.0 | ||
config: test/e2e/kind.yaml | ||
image: kindest/node:${{ matrix.k8s }} | ||
|
||
- uses: geekyeggo/delete-artifact@v1 | ||
with: | ||
name: docker.tar.gz | ||
failOnError: false | ||
|
||
- name: Prepare cluster for testing | ||
id: local-path | ||
run: | | ||
kubectl version | ||
echo | ||
echo "installing helm 3..." | ||
curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash | ||
- name: Load images from cache | ||
run: | | ||
echo "loading docker images..." | ||
pigz -dc docker.tar.gz | docker load | ||
- name: Run e2e tests | ||
env: | ||
KIND_CLUSTER_NAME: kind | ||
SKIP_CLUSTER_CREATION: true | ||
SKIP_IMAGE_CREATION: true | ||
IS_CHROOT: true | ||
run: | | ||
kind get kubeconfig > $HOME/.kube/kind-config-kind | ||
make kind-e2e-test | ||
test-image-build: | ||
permissions: | ||
contents: read # for dorny/paths-filter to fetch a list of changed files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"k8s.io/klog/v2" | ||
|
||
"gopkg.in/mcuadros/go-syslog.v2" | ||
) | ||
|
||
func logger(address string) { | ||
channel := make(syslog.LogPartsChannel) | ||
handler := syslog.NewChannelHandler(channel) | ||
|
||
server := syslog.NewServer() | ||
|
||
server.SetFormat(syslog.RFC3164) | ||
server.SetHandler(handler) | ||
if err := server.ListenUDP(address); err != nil { | ||
klog.Fatalf("failed bind internal syslog: %w", err) | ||
} | ||
|
||
if err := server.Boot(); err != nil { | ||
klog.Fatalf("failed to boot internal syslog: %w", err) | ||
} | ||
klog.Infof("Is Chrooted, starting logger") | ||
|
||
for logParts := range channel { | ||
fmt.Printf("%s\n", logParts["content"]) | ||
} | ||
|
||
server.Wait() | ||
klog.Infof("Stopping logger") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.