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

prepare v0.5.11 release #510

Merged
merged 13 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# For testing
test-artifacts
hack/e2e/e2e-test-artifacts

# == kubernetes .gitignore ==

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
ARG image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-12-01-1638322424

FROM --platform=$BUILDPLATFORM golang:1.16 AS builder
FROM --platform=$BUILDPLATFORM golang:1.19 AS builder
WORKDIR /go/src/github.com/kubernetes-sigs/aws-iam-authenticator
COPY . .
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make bin
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ test:
integration:
./hack/test-integration.sh

.PHONY: e2e
e2e: bin
ifeq ($(RUNNER),kops)
./hack/e2e/run.sh
else ifeq ($(RUNNER),kind)
./hack/start-dev-env-dynamicfile.sh
./hack/stop-dev-env.sh
else
echo "make e2e RUNNER=[kops|kind]"
endif

.PHONY: format
format:
test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)" || \
Expand Down Expand Up @@ -127,6 +138,14 @@ start-dev: bin
stop-dev:
./hack/stop-dev-env.sh

.PHONY: start-dev-dynamicfile-e2e
start-dev-dynamicfile:
./hack/start-dev-env-dynamicfile.sh

.PHONY: stop-dev-dynamicfile-e2e
stop-dev-dynamicfile:
./hack/stop-dev-env.sh

# Use make kill-dev when you want to remove a dev environment
# and clean everything up in preparation for creating another
# in the future.
Expand Down
39 changes: 28 additions & 11 deletions cmd/aws-iam-authenticator/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
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,
Expand All @@ -20,6 +20,9 @@ import (
"fmt"
"os"

"sigs.k8s.io/aws-iam-authenticator/pkg"
"sigs.k8s.io/aws-iam-authenticator/pkg/config"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -30,25 +33,39 @@ var initCmd = &cobra.Command{
Short: "Pre-generate certificate, private key, and kubeconfig files for the server.",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Authenticator Version: %q, %q\n", pkg.Version, pkg.CommitID)
cfg, err := getConfig()
if err != nil {
fmt.Fprintf(os.Stderr, "could not get config: %v\n", err)
os.Exit(1)
}

localCfg := cfg
localCfg.GenerateKubeconfigPath = "aws-iam-authenticator.kubeconfig"
localCfg.StateDir = "./"
if featureGates.Enabled(config.ConfiguredInitDirectories) {
if err := cfg.GenerateFiles(); err != nil {

err = localCfg.GenerateFiles()
if err != nil {
fmt.Fprintf(os.Stderr, "could not initialize: %v\n", err)
os.Exit(1)
fmt.Fprintf(os.Stderr, "could not initialize: %v\n", err)
os.Exit(1)
}

logrus.Infof("certificate generated at %s on kubernetes master node(s)", cfg.CertPath())
logrus.Infof("key generated at %s on kubernetes master node(s)", cfg.KeyPath())
logrus.Infof("kubeconfig generated at %s on kubernetes master node(s)", cfg.GenerateKubeconfigPath)
} else {
deprecatedCfg := cfg
deprecatedCfg.GenerateKubeconfigPath = "aws-iam-authenticator.kubeconfig"
deprecatedCfg.StateDir = "./"

err = deprecatedCfg.GenerateFiles()
if err != nil {
fmt.Fprintf(os.Stderr, "could not initialize: %v\n", err)
os.Exit(1)
}

logrus.Infof("copy %s to %s on kubernetes master node(s)", deprecatedCfg.CertPath(), cfg.CertPath())
logrus.Infof("copy %s to %s on kubernetes master node(s)", deprecatedCfg.KeyPath(), cfg.KeyPath())
logrus.Infof("copy %s to %s on kubernetes master node(s)", deprecatedCfg.GenerateKubeconfigPath, cfg.GenerateKubeconfigPath)
}

logrus.Infof("copy %s to %s on kubernetes master node(s)", localCfg.CertPath(), cfg.CertPath())
logrus.Infof("copy %s to %s on kubernetes master node(s)", localCfg.KeyPath(), cfg.KeyPath())
logrus.Infof("copy %s to %s on kubernetes master node(s)", localCfg.GenerateKubeconfigPath, cfg.GenerateKubeconfigPath)
logrus.Infof("configure your apiserver with `--authentication-token-webhook-config-file=%s` to enable authentication with aws-iam-authenticator", cfg.GenerateKubeconfigPath)
},
}
Expand Down
22 changes: 22 additions & 0 deletions cmd/aws-iam-authenticator/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func init() {

featureGates.Add(config.DefaultFeatureGates)
featureGates.AddFlag(rootCmd.PersistentFlags())

viper.BindPFlag("feature-gates", rootCmd.PersistentFlags().Lookup("feature-gates"))
}

func initConfig() {
Expand All @@ -84,6 +86,7 @@ func initConfig() {
}

func getConfig() (config.Config, error) {

cfg := config.Config{
PartitionID: viper.GetString("server.partition"),
ClusterID: viper.GetString("clusterID"),
Expand All @@ -100,6 +103,7 @@ func getConfig() (config.Config, error) {
EC2DescribeInstancesQps: viper.GetInt("server.ec2DescribeInstancesQps"),
EC2DescribeInstancesBurst: viper.GetInt("server.ec2DescribeInstancesBurst"),
ScrubbedAWSAccounts: viper.GetStringSlice("server.scrubbedAccounts"),
DynamicFilePath: viper.GetString("server.dynamicfilepath"),
}
if err := viper.UnmarshalKey("server.mapRoles", &cfg.RoleMappings); err != nil {
return cfg, fmt.Errorf("invalid server role mappings: %v", err)
Expand All @@ -111,6 +115,10 @@ func getConfig() (config.Config, error) {
logrus.WithError(err).Fatal("invalid server account mappings")
}

if featureGates.Enabled(config.ConfiguredInitDirectories) {
logrus.Info("ConfiguredInitDirectories feature enabled")
}

if cfg.ClusterID == "" {
return cfg, errors.New("cluster ID cannot be empty")
}
Expand All @@ -125,6 +133,20 @@ func getConfig() (config.Config, error) {
return cfg, errors.New("Invalid partition")
}

// DynamicFile BackendMode and DynamicFilePath are mutually inclusive.
var dynamicFileModeSet bool
for _, mode := range cfg.BackendMode {
if mode == mapper.ModeDynamicFile {
dynamicFileModeSet = true
}
}
if dynamicFileModeSet && cfg.DynamicFilePath == "" {
logrus.Fatal("dynamicfile is set in backend-mode but dynamicfilepath is not set")
}
if !dynamicFileModeSet && cfg.DynamicFilePath != "" {
logrus.Fatal("dynamicfile is not set in backend-mode but dynamicfilepath is set")
}

if errs := mapper.ValidateBackendMode(cfg.BackendMode); len(errs) > 0 {
return cfg, utilerrors.NewAggregate(errs)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/aws-iam-authenticator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"k8s.io/sample-controller/pkg/signals"
"sigs.k8s.io/aws-iam-authenticator/pkg"
"sigs.k8s.io/aws-iam-authenticator/pkg/mapper"
"sigs.k8s.io/aws-iam-authenticator/pkg/metrics"
"sigs.k8s.io/aws-iam-authenticator/pkg/server"
Expand All @@ -48,6 +49,7 @@ var serverCmd = &cobra.Command{
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
var err error
fmt.Printf("Authenticator Version: %q, %q\n", pkg.Version, pkg.CommitID)
metrics.InitMetrics(prometheus.DefaultRegisterer)
stopCh := signals.SetupSignalHandler()

Expand Down
Empty file added empty
Empty file.
35 changes: 35 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ go 1.16

require (
github.com/aws/aws-sdk-go v1.44.107
github.com/fsnotify/fsnotify v1.4.9
github.com/gofrs/flock v0.7.0
github.com/manifoldco/promptui v0.9.0
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/prometheus/client_golang v1.11.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
Expand All @@ -17,6 +20,38 @@ require (
k8s.io/client-go v0.22.1
k8s.io/code-generator v0.22.1
k8s.io/component-base v0.22.1
k8s.io/kubernetes v1.22.0
k8s.io/sample-controller v0.22.1
sigs.k8s.io/yaml v1.2.0
)

replace (
k8s.io.client-go => k8s.io/client-go v0.20.0
k8s.io/api => k8s.io/api v0.22.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.22.0
k8s.io/apimachinery => k8s.io/apimachinery v0.23.0-alpha.0
k8s.io/apiserver => k8s.io/apiserver v0.22.0
k8s.io/cli-runtime => k8s.io/cli-runtime v0.22.0
k8s.io/client-go => k8s.io/client-go v0.22.0
k8s.io/cloud-provider => k8s.io/cloud-provider v0.22.0
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.22.0
k8s.io/code-generator => k8s.io/code-generator v0.22.2-rc.0
k8s.io/component-base => k8s.io/component-base v0.22.0
k8s.io/component-helpers => k8s.io/component-helpers v0.22.0
k8s.io/controller-manager => k8s.io/controller-manager v0.22.0
k8s.io/cri-api => k8s.io/cri-api v0.23.0-alpha.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.22.0
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.22.0
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.22.0
k8s.io/kube-proxy => k8s.io/kube-proxy v0.22.0
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.22.0
k8s.io/kubectl => k8s.io/kubectl v0.22.0
k8s.io/kubelet => k8s.io/kubelet v0.22.0
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.22.0
k8s.io/metrics => k8s.io/metrics v0.22.0
k8s.io/mount-utils => k8s.io/mount-utils v0.22.1-rc.0
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.22.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.22.0
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.22.0
k8s.io/sample-controller => k8s.io/sample-controller v0.22.0
)
Loading