Skip to content

Commit cc3fb48

Browse files
committed
tls: switch to self-signed admin.kubeconfig
The KAS now trusts the admin.kubeconfig client cert. We can remove the old kube-ca signed admin.kubeconfig to more appropriately scope trust.
1 parent 6b6b55b commit cc3fb48

File tree

4 files changed

+5
-88
lines changed

4 files changed

+5
-88
lines changed

pkg/asset/ignition/bootstrap/bootstrap.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ var _ asset.WritableAsset = (*Bootstrap)(nil)
6262
func (a *Bootstrap) Dependencies() []asset.Asset {
6363
return []asset.Asset{
6464
&installconfig.InstallConfig{},
65-
&kubeconfig.Admin{},
6665
&kubeconfig.AdminClient{},
6766
&kubeconfig.Kubelet{},
6867
&kubeconfig.KubeletClient{},
@@ -373,7 +372,6 @@ func (a *Bootstrap) addParentFiles(dependencies asset.Parents) {
373372
}
374373

375374
for _, asset := range []asset.WritableAsset{
376-
&kubeconfig.Admin{},
377375
&kubeconfig.AdminClient{},
378376
&kubeconfig.Kubelet{},
379377
&kubeconfig.KubeletClient{},

pkg/asset/kubeconfig/admin.go

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,9 @@ import (
99
)
1010

1111
var (
12-
kubeconfigAdminPath = filepath.Join("auth", "kubeconfig")
13-
kubeconfigAdminClientPath = filepath.Join("auth", "kubeconfig-admin")
12+
kubeconfigAdminPath = filepath.Join("auth", "kubeconfig")
1413
)
1514

16-
// Admin is the asset for the admin kubeconfig.
17-
// [DEPRECATED]
18-
type Admin struct {
19-
kubeconfig
20-
}
21-
22-
var _ asset.WritableAsset = (*Admin)(nil)
23-
24-
// Dependencies returns the dependency of the kubeconfig.
25-
func (k *Admin) Dependencies() []asset.Asset {
26-
return []asset.Asset{
27-
&tls.KubeCA{},
28-
&tls.AdminCertKey{},
29-
&installconfig.InstallConfig{},
30-
}
31-
}
32-
33-
// Generate generates the kubeconfig.
34-
func (k *Admin) Generate(parents asset.Parents) error {
35-
kubeCA := &tls.KubeCA{}
36-
adminCertKey := &tls.AdminCertKey{}
37-
installConfig := &installconfig.InstallConfig{}
38-
parents.Get(kubeCA, adminCertKey, installConfig)
39-
40-
return k.kubeconfig.generate(
41-
kubeCA,
42-
adminCertKey,
43-
installConfig.Config,
44-
"admin",
45-
kubeconfigAdminPath,
46-
)
47-
}
48-
49-
// Name returns the human-friendly name of the asset.
50-
func (k *Admin) Name() string {
51-
return "Kubeconfig Admin"
52-
}
53-
54-
// Load returns the kubeconfig from disk.
55-
func (k *Admin) Load(f asset.FileFetcher) (found bool, err error) {
56-
return k.load(f, kubeconfigAdminPath)
57-
}
58-
5915
// AdminClient is the asset for the admin kubeconfig.
6016
type AdminClient struct {
6117
kubeconfig
@@ -84,7 +40,7 @@ func (k *AdminClient) Generate(parents asset.Parents) error {
8440
clientCertKey,
8541
installConfig.Config,
8642
"admin",
87-
kubeconfigAdminClientPath,
43+
kubeconfigAdminPath,
8844
)
8945
}
9046

@@ -95,5 +51,5 @@ func (k *AdminClient) Name() string {
9551

9652
// Load returns the kubeconfig from disk.
9753
func (k *AdminClient) Load(f asset.FileFetcher) (found bool, err error) {
98-
return k.load(f, kubeconfigAdminClientPath)
54+
return k.load(f, kubeconfigAdminPath)
9955
}

pkg/asset/targets/targets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var (
4848

4949
// IgnitionConfigs are the ignition-configs targeted assets.
5050
IgnitionConfigs = []asset.WritableAsset{
51-
&kubeconfig.Admin{},
51+
&kubeconfig.AdminClient{},
5252
&machine.Master{},
5353
&machine.Worker{},
5454
&bootstrap.Bootstrap{},
@@ -58,7 +58,7 @@ var (
5858
// Cluster are the cluster targeted assets.
5959
Cluster = []asset.WritableAsset{
6060
&cluster.TerraformVariables{},
61-
&kubeconfig.Admin{},
61+
&kubeconfig.AdminClient{},
6262
&tls.JournalCertKey{},
6363
&cluster.Metadata{},
6464
&cluster.Cluster{},

pkg/asset/tls/adminkubeconfig.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,6 @@ import (
77
"github.com/openshift/installer/pkg/asset"
88
)
99

10-
//AdminCertKey is the asset that generates the admin key/cert pair.
11-
// [DEPRECATED]
12-
type AdminCertKey struct {
13-
SignedCertKey
14-
}
15-
16-
var _ asset.WritableAsset = (*AdminCertKey)(nil)
17-
18-
// Dependencies returns the dependency of the the cert/key pair, which includes
19-
// the parent CA, and install config if it depends on the install config for
20-
// DNS names, etc.
21-
func (a *AdminCertKey) Dependencies() []asset.Asset {
22-
return []asset.Asset{
23-
&KubeCA{},
24-
}
25-
}
26-
27-
// Generate generates the cert/key pair based on its dependencies.
28-
func (a *AdminCertKey) Generate(dependencies asset.Parents) error {
29-
kubeCA := &KubeCA{}
30-
dependencies.Get(kubeCA)
31-
32-
cfg := &CertCfg{
33-
Subject: pkix.Name{CommonName: "system:admin", Organization: []string{"system:masters"}},
34-
KeyUsages: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
35-
ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
36-
Validity: ValidityTenYears,
37-
}
38-
39-
return a.SignedCertKey.Generate(cfg, kubeCA, "admin", DoNotAppendParent)
40-
}
41-
42-
// Name returns the human-friendly name of the asset.
43-
func (a *AdminCertKey) Name() string {
44-
return "Certificate (system:admin)"
45-
}
46-
4710
// AdminKubeConfigSignerCertKey is a key/cert pair that signs the admin kubeconfig client certs.
4811
type AdminKubeConfigSignerCertKey struct {
4912
SelfSignedCertKey

0 commit comments

Comments
 (0)