Skip to content

Commit

Permalink
Node Secrets
Browse files Browse the repository at this point in the history
As present a number of secrets are downloaded to the /src/kubernetes directory regardless of role (master, node). This limits the
the node role to only donwload the ca.crt. The rest are for master nodes only

- removes basic_auth.csv, ca.key, known_tokens.csv, server.cert and server.key leaving only the ca.crt
  • Loading branch information
gambol99 committed Jul 26, 2017
1 parent c9e651b commit d9da2f5
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions nodeup/pkg/model/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package model

import (
"fmt"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"path/filepath"
"strings"

"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
)

// SecretBuilder writes secrets
Expand All @@ -31,11 +32,13 @@ type SecretBuilder struct {

var _ fi.ModelBuilder = &SecretBuilder{}

// Build is responisble for pulling down the secrets
func (b *SecretBuilder) Build(c *fi.ModelBuilderContext) error {
if b.KeyStore == nil {
return fmt.Errorf("KeyStore not set")
}

// retrieve the platform ca
{
ca, err := b.KeyStore.CertificatePool(fi.CertificateId_CA)
if err != nil {
Expand All @@ -55,7 +58,13 @@ func (b *SecretBuilder) Build(c *fi.ModelBuilderContext) error {
c.AddTask(t)
}

{
// if we are not a master we can stop here
if !b.IsMaster {
return nil
}

// grab the server.{key,cert} from keystore
for _, filename := range []string{"server.cert", "server.key"} {
cert, err := b.KeyStore.Cert("master")
if err != nil {
return err
Expand All @@ -67,25 +76,7 @@ func (b *SecretBuilder) Build(c *fi.ModelBuilderContext) error {
}

t := &nodetasks.File{
Path: filepath.Join(b.PathSrvKubernetes(), "server.cert"),
Contents: fi.NewStringResource(serialized),
Type: nodetasks.FileType_File,
}
c.AddTask(t)
}
{
k, err := b.KeyStore.PrivateKey("master")
if err != nil {
return err
}

serialized, err := k.AsString()
if err != nil {
return err
}

t := &nodetasks.File{
Path: filepath.Join(b.PathSrvKubernetes(), "server.key"),
Path: filepath.Join(b.PathSrvKubernetes(), filename),
Contents: fi.NewStringResource(serialized),
Type: nodetasks.FileType_File,
}
Expand Down

0 comments on commit d9da2f5

Please sign in to comment.