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

OIDC state machine #384

Merged
merged 44 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
32bcb2f
WiP draft of boostraping OIDC fsm
Disper Sep 10, 2024
e6f4b3a
Merge branch 'main' into oidc-fullblown
Disper Sep 12, 2024
a8d0e36
fixes logger panics
Disper Sep 12, 2024
db4a716
creating OpenIDConnect on shoot with fake data
Disper Sep 13, 2024
c034a7f
defaults additionalOidcs if not set and uses actual data in openidcon…
Disper Sep 13, 2024
d52e212
creates OpenIdConnect CRs only if extension is enabled
Disper Sep 16, 2024
77e50eb
adds OIDC conditions
Disper Sep 16, 2024
1a93c9d
Merge branch 'main' into oidc-fullblown
Disper Sep 17, 2024
d51eda9
oidc state is moved from last to be before CRB state
Disper Sep 17, 2024
2e927ee
golangci-lint run --fix
Disper Sep 17, 2024
a5b648c
further lint fixes around oidc fsm
Disper Sep 17, 2024
6e95ce1
attempt to fix trivy and imports reordering
Disper Sep 17, 2024
83a8553
replaces indirect dependency of go-jose from 2.6.0 to 4.0.4 to fix cv…
Disper Sep 17, 2024
85ae26c
replaces go-jose/v4 4.0.4 with go-jose/v2 2.6.3 which is closer major…
Disper Sep 17, 2024
474b535
Revert "replaces go-jose/v4 4.0.4 with go-jose/v2 2.6.3 which is clos…
Disper Sep 17, 2024
538b69c
fixes runtime controller tests
Disper Sep 18, 2024
1a01f47
fixes linter
Disper Sep 18, 2024
a3e67b9
Merge branch 'main' into oidc-fullblown
Disper Sep 18, 2024
3845a58
WiP work on oidc/additionalOidc defaults
Disper Sep 20, 2024
6c15d44
OIDCConfig is now optional
Disper Sep 20, 2024
75771f8
Merge branch 'oidcconfig_no_longer_required' into oidc-fullblown
Disper Sep 23, 2024
81be84e
clean-ups the code around defaulting oidc
Disper Sep 24, 2024
6c97080
linter fixes
Disper Sep 24, 2024
9bc3152
fixes converter test after adding new fields
Disper Sep 24, 2024
9e92dc3
recreate oiddopenconnect CRs
Disper Sep 24, 2024
369b974
fixes incorrect return statements in oidc fsm
Disper Sep 25, 2024
94b3034
linter
Disper Sep 25, 2024
66a3039
applying review remarks
Disper Oct 1, 2024
806497a
applying review remarks
Disper Oct 1, 2024
751ad5e
Merge branch 'main' into oidc-fullblown
Disper Oct 1, 2024
a1751fa
extends ConverterConfig to be InfrastructureManagerConfig
Disper Oct 1, 2024
233f13f
NewOidcExtender uses InfrastructureManagerConfig.OidcProvider
Disper Oct 1, 2024
25a1133
InfrastructureManagerConfig.Converter refactoring
Disper Oct 1, 2024
b764bcd
deletes OpenIDConnect CRs using label selector
Disper Oct 1, 2024
aebad26
Merge branch 'main' into oidc-fullblown
Disper Oct 1, 2024
af160bf
fixes Test_ConverterConfig_Load_OK
Disper Oct 2, 2024
44723b0
fixes metrics.yaml
Disper Oct 2, 2024
e1ae536
adds oidc fsm testcase for disabled extension
Disper Oct 2, 2024
3294aa4
moves KIM config from internal package to internal/config
Disper Oct 2, 2024
8e252c2
linter fixes
Disper Oct 2, 2024
080bc57
unit tests for oidc fsm
Disper Oct 4, 2024
f22f47b
Code review remarks: tests check all fields of the OpenOIDC CR
akgalwas Oct 10, 2024
2b65f12
Merge branch 'main' into oidc-fullblown
akgalwas Oct 10, 2024
4a7aac4
Merge branch 'main' into oidc-fullblown
akgalwas Oct 14, 2024
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
5 changes: 4 additions & 1 deletion api/v1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
ConditionTypeRuntimeProvisioned RuntimeConditionType = "Provisioned"
ConditionTypeRuntimeProvisionedDryRun RuntimeConditionType = "ProvisionedDryRun"
ConditionTypeRuntimeKubeconfigReady RuntimeConditionType = "KubeconfigReady"
ConditionTypeOidcConfigured RuntimeConditionType = "OidcConfigured"
ConditionTypeRuntimeConfigured RuntimeConditionType = "Configured"
ConditionTypeAuditLogConfigured RuntimeConditionType = "AuditlogConfigured"
ConditionTypeRuntimeDeprovisioned RuntimeConditionType = "Deprovisioned"
Expand Down Expand Up @@ -100,6 +101,8 @@ const (
ConditionReasonAuditLogConfigured = RuntimeConditionReason("AuditLogConfigured")
ConditionReasonAuditLogError = RuntimeConditionReason("AuditLogErr")
ConditionReasonAuditLogMissingRegionMapping = RuntimeConditionReason("AuditLogMissingRegionMappingErr")
ConditionReasonOidcConfigured = RuntimeConditionReason("OidcConfigured")
ConditionReasonOidcError = RuntimeConditionReason("OidcConfigurationErr")
)

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -164,7 +167,7 @@ type Kubernetes struct {
}

type APIServer struct {
OidcConfig gardener.OIDCConfig `json:"oidcConfig"`
OidcConfig gardener.OIDCConfig `json:"oidcConfig,omitempty"`
AdditionalOidcConfig *[]gardener.OIDCConfig `json:"additionalOidcConfig,omitempty"`
}

Expand Down
22 changes: 15 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ import (

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
gardener_apis "github.com/gardener/gardener/pkg/client/core/clientset/versioned/typed/core/v1beta1"
gardener_oidc "github.com/gardener/oidc-webhook-authenticator/apis/authentication/v1alpha1"
"github.com/go-playground/validator/v10"
infrastructuremanagerv1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/infrastructure-manager/internal/auditlogging"
"github.com/kyma-project/infrastructure-manager/internal/config"
kubeconfig_controller "github.com/kyma-project/infrastructure-manager/internal/controller/kubeconfig"
"github.com/kyma-project/infrastructure-manager/internal/controller/metrics"
runtime_controller "github.com/kyma-project/infrastructure-manager/internal/controller/runtime"
"github.com/kyma-project/infrastructure-manager/internal/controller/runtime/fsm"
"github.com/kyma-project/infrastructure-manager/internal/gardener"
"github.com/kyma-project/infrastructure-manager/internal/gardener/kubeconfig"
"github.com/kyma-project/infrastructure-manager/internal/gardener/shoot"
"github.com/pkg/errors"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -58,6 +59,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(infrastructuremanagerv1.AddToScheme(scheme))
utilruntime.Must(rbacv1.AddToScheme(scheme))
utilruntime.Must(gardener_oidc.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -163,7 +165,7 @@ func main() {
getReader := func() (io.Reader, error) {
return os.Open(converterConfigFilepath)
}
var converterConfig shoot.ConverterConfig
var converterConfig config.Config
if err = converterConfig.Load(getReader); err != nil {
setupLog.Error(err, "unable to load converter configuration")
os.Exit(1)
Expand All @@ -175,7 +177,7 @@ func main() {
os.Exit(1)
}

err = validateAuditLogConfiguration(converterConfig.AuditLog.TenantConfigPath)
err = validateAuditLogConfiguration(converterConfig.ConverterConfig.AuditLog.TenantConfigPath)
if err != nil {
setupLog.Error(err, "invalid Audit Log configuration")
os.Exit(1)
Expand All @@ -184,7 +186,7 @@ func main() {
cfg := fsm.RCCfg{
Finalizer: infrastructuremanagerv1.Finalizer,
ShootNamesapace: gardenerNamespace,
ConverterConfig: converterConfig,
Config: converterConfig,
AuditLogMandatory: auditLogMandatory,
}
if shootSpecDumpEnabled {
Expand Down Expand Up @@ -240,13 +242,19 @@ func initGardenerClients(kubeconfigPath string, namespace string) (client.Client
return nil, nil, nil, err
}

shootClient := gardenerClientSet.Shoots(namespace)
dynamicKubeconfigAPI := gardenerClient.SubResource("adminkubeconfig")

err = v1beta1.AddToScheme(gardenerClient.Scheme())
if err != nil {
return nil, nil, nil, errors.Wrap(err, "failed to register Gardener schema")
}

err = gardener_oidc.AddToScheme(gardenerClient.Scheme())
if err != nil {
return nil, nil, nil, errors.Wrap(err, "failed to register Gardener schema")
}

shootClient := gardenerClientSet.Shoots(namespace)
dynamicKubeconfigAPI := gardenerClient.SubResource("adminkubeconfig")

return gardenerClient, shootClient, dynamicKubeconfigAPI, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ spec:
the value '-'.
type: string
type: object
required:
- oidcConfig
type: object
version:
type: string
Expand Down
20 changes: 12 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/gardener/gardener-extension-provider-aws v1.56.1
github.com/gardener/gardener-extension-provider-gcp v1.37.0
github.com/gardener/gardener-extension-provider-openstack v1.41.0
github.com/gardener/oidc-webhook-authenticator v0.31.0
github.com/go-logr/logr v1.4.2
github.com/go-playground/validator/v10 v10.22.0
github.com/onsi/ginkgo/v2 v2.20.2
Expand All @@ -25,24 +26,25 @@ require (
require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect
Expand All @@ -58,9 +60,9 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand All @@ -77,11 +79,12 @@ require (
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Expand All @@ -91,4 +94,5 @@ replace (
golang.org/x/sys => golang.org/x/sys v0.21.0
golang.org/x/text => golang.org/x/text v0.16.0
golang.org/x/tools => golang.org/x/tools v0.22.0
gopkg.in/square/go-jose.v2 => github.com/go-jose/go-jose/v4 v4.0.4
)
Loading
Loading