-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to a slimmer distroless base image.
At a high level, it switches us to a distroless base container image, but that also includes several related bits: - Add a writable /tmp but make the rest of our filesystems read-only at runtime. - Condense our main server binaries into a single pinniped-server binary. This saves a bunch of space in the image due to duplicated library code. The correct behavior is dispatched based on `os.Args[0]`, and the `pinniped-server` binary is symlinked to `pinniped-concierge` and `pinniped-supervisor`. - Strip debug symbols from our binaries. These aren't really useful in a distroless image anyway and all the normal stuff you'd expect to work, such as stack traces, still does. - Add a separate `pinniped-concierge-kube-cert-agent` binary with "sleep" and "print" functionality instead of using builtin /bin/sleep and /bin/cat for the kube-cert-agent. This is split from the main server binary because the loading/init time of the main server binary was too large for the tiny resource footprint we established in our kube-cert-agent PodSpec. Using a separate binary eliminates this issue and the extra binary adds only around 1.5MiB of image size. - Switch the kube-cert-agent code to use a JSON `{"tls.crt": "<b64 cert>", "tls.key": "<b64 key>"}` format. This is more robust to unexpected input formatting than the old code, which simply concatenated the files with some extra newlines and split on whitespace. - Update integration tests that made now-invalid assumptions about the `pinniped-server` image. Signed-off-by: Matt Moyer <moyerm@vmware.com>
- Loading branch information
Showing
19 changed files
with
540 additions
and
107 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
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,55 @@ | ||
// Copyright 2021 the Pinniped contributors. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package main is the combined entrypoint for the Pinniped "kube-cert-agent" component. | ||
package main | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"io" | ||
"io/ioutil" | ||
"log" | ||
"math" | ||
"os" | ||
"time" | ||
) | ||
|
||
//nolint: gochecknoglobals // these are swapped during unit tests. | ||
var ( | ||
getenv = os.Getenv | ||
fail = log.Fatalf | ||
sleep = time.Sleep | ||
out = io.Writer(os.Stdout) | ||
) | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
fail("missing subcommand") | ||
} | ||
|
||
switch os.Args[1] { | ||
case "sleep": | ||
sleep(math.MaxInt64) | ||
case "print": | ||
certBytes, err := ioutil.ReadFile(getenv("CERT_PATH")) | ||
if err != nil { | ||
fail("could not read CERT_PATH: %v", err) | ||
} | ||
keyBytes, err := ioutil.ReadFile(getenv("KEY_PATH")) | ||
if err != nil { | ||
fail("could not read KEY_PATH: %v", err) | ||
} | ||
if err := json.NewEncoder(out).Encode(&struct { | ||
Cert string `json:"tls.crt"` | ||
Key string `json:"tls.key"` | ||
}{ | ||
Cert: base64.StdEncoding.EncodeToString(certBytes), | ||
Key: base64.StdEncoding.EncodeToString(keyBytes), | ||
}); err != nil { | ||
fail("failed to write output: %v", err) | ||
} | ||
default: | ||
fail("invalid subcommand %q", os.Args[1]) | ||
} | ||
} |
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,128 @@ | ||
// Copyright 2021 the Pinniped contributors. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"log" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type errWriter struct{} | ||
|
||
func (e errWriter) Write([]byte) (int, error) { return 0, fmt.Errorf("some write error") } | ||
|
||
func TestEntrypoint(t *testing.T) { | ||
for _, tt := range []struct { | ||
name string | ||
args []string | ||
env map[string]string | ||
failOutput bool | ||
wantSleep time.Duration | ||
wantLog string | ||
wantOutJSON string | ||
wantFail bool | ||
}{ | ||
{ | ||
name: "missing args", | ||
args: []string{}, | ||
wantLog: "missing subcommand\n", | ||
wantFail: true, | ||
}, | ||
{ | ||
name: "invalid subcommand", | ||
args: []string{"/path/to/binary", "invalid"}, | ||
wantLog: "invalid subcommand \"invalid\"\n", | ||
wantFail: true, | ||
}, | ||
{ | ||
name: "valid sleep", | ||
args: []string{"/path/to/binary", "sleep"}, | ||
wantSleep: 2562047*time.Hour + 47*time.Minute + 16*time.Second + 854775807*time.Nanosecond, // math.MaxInt64 nanoseconds, approximately 290 years | ||
}, | ||
{ | ||
name: "missing cert file", | ||
args: []string{"/path/to/binary", "print"}, | ||
env: map[string]string{ | ||
"CERT_PATH": "./does/not/exist", | ||
"KEY_PATH": "./testdata/test.key", | ||
}, | ||
wantFail: true, | ||
wantLog: "could not read CERT_PATH: open ./does/not/exist: no such file or directory\n", | ||
}, | ||
{ | ||
name: "missing key file", | ||
args: []string{"/path/to/binary", "print"}, | ||
env: map[string]string{ | ||
"CERT_PATH": "./testdata/test.crt", | ||
"KEY_PATH": "./does/not/exist", | ||
}, | ||
wantFail: true, | ||
wantLog: "could not read KEY_PATH: open ./does/not/exist: no such file or directory\n", | ||
}, | ||
{ | ||
name: "fail to write output", | ||
args: []string{"/path/to/binary", "print"}, | ||
env: map[string]string{ | ||
"CERT_PATH": "./testdata/test.crt", | ||
"KEY_PATH": "./testdata/test.key", | ||
}, | ||
failOutput: true, | ||
wantFail: true, | ||
wantLog: "failed to write output: some write error\n", | ||
}, | ||
{ | ||
name: "successful print", | ||
args: []string{"/path/to/binary", "print"}, | ||
env: map[string]string{ | ||
"CERT_PATH": "./testdata/test.crt", | ||
"KEY_PATH": "./testdata/test.key", | ||
}, | ||
wantOutJSON: `{ | ||
"tls.crt": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdw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eFVFc081ZGZUcFNUR0RQdnFwTkQ5bmlGVlVXcVZpN29UTnE2ZXA5eVF0bDVTQURqcXhxCjRTQUJBb0dBSW0waFVnMXd0Y1M0NmNHTHk2UElrUE01dG9jVFNnaHR6NHZGc3VrL2k0UUE5R0JvQk8yZ0g2dHkKK2tKSG1lYVh0MmRtZ3lTcDBRQVdpdDVVbGNlRXVtQjBOWG5BZEpaUXhlR1NGU3lZa0RXaHdYZDh3RGNlS28vMQpMZkNVNkRrOElOL1NzcHBWVVdYUTJybE9SdnhsckhlQ2lvOG8wa1M5WWl1NTVXTVlnNGc9Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==" | ||
}`, | ||
}, | ||
} { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
var logBuf bytes.Buffer | ||
testLog := log.New(&logBuf, "", 0) | ||
exited := "exiting via fatal" | ||
fail = func(format string, v ...interface{}) { | ||
testLog.Printf(format, v...) | ||
panic(exited) | ||
} | ||
|
||
var sawSleep time.Duration | ||
sleep = func(d time.Duration) { sawSleep = d } | ||
|
||
var sawOutput bytes.Buffer | ||
out = &sawOutput | ||
if tt.failOutput { | ||
out = &errWriter{} | ||
} | ||
|
||
os.Args = tt.args | ||
getenv = func(key string) string { return tt.env[key] } | ||
if tt.wantFail { | ||
require.PanicsWithValue(t, exited, main) | ||
} else { | ||
require.NotPanics(t, main) | ||
} | ||
require.Equal(t, tt.wantSleep.String(), sawSleep.String()) | ||
require.Equal(t, tt.wantLog, logBuf.String()) | ||
if tt.wantOutJSON == "" { | ||
require.Empty(t, sawOutput.String()) | ||
} else { | ||
require.JSONEq(t, tt.wantOutJSON, sawOutput.String()) | ||
} | ||
}) | ||
} | ||
} |
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,17 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl | ||
cm5ldGVzMB4XDTIwMDcyNTIxMDQxOFoXDTMwMDcyMzIxMDQxOFowFTETMBEGA1UE | ||
AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3K | ||
hYv2gIQ1Dwzh2cWMid+ofAnvLIfV2Xv61vTLGprUI+XUqB4/gtf6X6UNn0Lett2n | ||
d8p4wy7hw73hU/ggdvmWJvqBrSjc3JGfy+kj66fKXX+PTlbL7QbwiRvcSqIXIWlV | ||
lHHxECWrED8jCulw/NVqfook/h5iNUCT9yswSJr/0fImiVnoTlIoEYG2eCNejZ5c | ||
g39uD3ZTqd9ZxWwSLLnI+2kpJnZBPcd1ZQ8AQqzDgZtYRCqacn5gckQUKZWKQlxo | ||
Eft6g1XHJouAWAZw7hEtk0v8rG0/eKF7wamxFi6BFVlbjWBsB4T9rApbdBWTKeCJ | ||
Hv8fv5RMFSzpT3uzTO8CAwEAAaMjMCEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB | ||
/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBACh5RhbxqJe+Z/gc17cZhKNmdiwu | ||
I2pLp3QBfwvN+Wbmajzw/7rYhY0d8JYVTJzXSCPWi6UAKxAtXOLF8WIIf9i39n6R | ||
uKOBGW14FzzGyRJiD3qaG/JTvEW+SLhwl68Ndr5LHSnbugAqq31abcQy6Zl9v5A8 | ||
JKC97Lj/Sn8rj7opKy4W3oq7NCQsAb0zh4IllRF6UvSnJySfsg7xdXHHpxYDHtOS | ||
XcOu5ySUIZTgFe9RfeUZlGZ5xn0ckMlQ7qW2Wx1q0OVWw5us4NtkGqKrHG4Tn1X7 | ||
uwo/Yytn5sDxrDv1/oii6AZOCsTPre4oD3wz4nmVzCVJcgrqH4Q24hT8WNg= | ||
-----END CERTIFICATE----- |
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,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEAvcqFi/aAhDUPDOHZxYyJ36h8Ce8sh9XZe/rW9MsamtQj5dSo | ||
Hj+C1/pfpQ2fQt623ad3ynjDLuHDveFT+CB2+ZYm+oGtKNzckZ/L6SPrp8pdf49O | ||
VsvtBvCJG9xKohchaVWUcfEQJasQPyMK6XD81Wp+iiT+HmI1QJP3KzBImv/R8iaJ | ||
WehOUigRgbZ4I16NnlyDf24PdlOp31nFbBIsucj7aSkmdkE9x3VlDwBCrMOBm1hE | ||
KppyfmByRBQplYpCXGgR+3qDVccmi4BYBnDuES2TS/ysbT94oXvBqbEWLoEVWVuN | ||
YGwHhP2sClt0FZMp4Ike/x+/lEwVLOlPe7NM7wIDAQABAoIBAFC1tUEmHNUcM0BJ | ||
M3D9KQzB+63F1mwVlx1QOOV1EeVR3co5Ox1R6PSr9sycFGQ9jgqI0zp5TJe9Tp6L | ||
GkhklfPh1MWnK9o6wlnzWKXWrrp2Jni+mpPyuOPAmq4Maniv2XeP+0bROwqpyojv | ||
AA7yC7M+TH226ZJGNVs3EV9+cwHml0yuzBfIJn/rv/w2g+WRKM/MC0S7k2d8bRlA | ||
NycKVGAGBhKTltjoVYOeh6aHEpSjK8zfaePjo5dYJvoVIli60YCgcJOU/8jXT+Np | ||
1Fm7tRvAtj3pUp0Sqdaf2RUzh9jfJp2VFCHuSJ6TPqArOyQojtMcTHF0TiW7xrHP | ||
xOCRIAECgYEAwGBPU7vdthMJBg+ORUoGQQaItTeJvQwIqJvbKD2osp4jhS1dGZBw | ||
W30GKEc/gd8JNtOq9BBnMicPF7hktuy+bSPv41XPud67rSSO7Tsw20C10gFRq06B | ||
zIJWFAUqK3IkvVc3VDmtSLSDox4QZ/BdqaMlQ5y5JCsC5kThmkZFlO8CgYEA/I9X | ||
YHi6RioMJE1fqOHJL4DDjlezmcuRrD7fE5InKbtJZ2JhGYOX/C0KXnHTOWTCDxxN | ||
FBvpvD6Xv5o3PhB9Z6k2fqvJ4GS8urkG/KU4xcC+bak+9ava8oaiSqG16zD9NH2P | ||
jJ60NrbLl1J0pU9fiwuFVUKJ4hDZOfN9RqYdyAECgYAVwo8WhJiGgM6zfcz073OX | ||
pVqPTPHqjVLpZ3+5pIfRdGvGI6R1QM5EuvaYVb7MPOM47WZX5wcVOC/P2g6iVlMP | ||
21HGIC2384a9BfaYxOo40q/+SiHnw6CQ9mkwKIllkqqvNA9RGpkMMUb2i28For2l | ||
c4vCgxa6DZdtXns6TRqPxwKBgCfY5cxOv/T6BVhk7MbUeM2J31DB/ZAyUhV/Bess | ||
kAlBh19MYk2IOZ6L7KriApV3lDaWHIMjtEkDByYvyq98Io0MYZCywfMpca10K+oI | ||
l2B7/I+IuGpCZxUEsO5dfTpSTGDPvqpND9niFVUWqVi7oTNq6ep9yQtl5SADjqxq | ||
4SABAoGAIm0hUg1wtcS46cGLy6PIkPM5tocTSghtz4vFsuk/i4QA9GBoBO2gH6ty | ||
+kJHmeaXt2dmgySp0QAWit5UlceEumB0NXnAdJZQxeGSFSyYkDWhwXd8wDceKo/1 | ||
LfCU6Dk8IN/SsppVUWXQ2rlORvxlrHeCio8o0kS9Yiu55WMYg4g= | ||
-----END RSA PRIVATE KEY----- |
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
// Copyright 2021 the Pinniped contributors. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package main is the combined entrypoint for all Pinniped server components. | ||
// | ||
// It dispatches to the appropriate Main() entrypoint based the name it is invoked as (os.Args[0]). In our server | ||
// container image, this binary is symlinked to several names such as `/usr/local/bin/pinniped-concierge`. | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/klog/v2" | ||
|
||
concierge "go.pinniped.dev/internal/concierge/server" | ||
lua "go.pinniped.dev/internal/localuserauthenticator" | ||
supervisor "go.pinniped.dev/internal/supervisor/server" | ||
) | ||
|
||
//nolint: gochecknoglobals // these are swapped during unit tests. | ||
var ( | ||
fail = klog.Fatalf | ||
subcommands = map[string]func(){ | ||
"pinniped-concierge": concierge.Main, | ||
"pinniped-supervisor": supervisor.Main, | ||
"local-user-authenticator": lua.Main, | ||
} | ||
) | ||
|
||
func main() { | ||
if len(os.Args) == 0 { | ||
fail("missing os.Args") | ||
} | ||
binary := filepath.Base(os.Args[0]) | ||
if subcommands[binary] == nil { | ||
fail("must be invoked as one of %v, not %q", sets.StringKeySet(subcommands).List(), binary) | ||
} | ||
subcommands[binary]() | ||
} |
Oops, something went wrong.