Skip to content

Commit

Permalink
Issue kube-controller-manager cert in nodeup
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Jun 10, 2020
1 parent bf11a65 commit d604212
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 39 deletions.
9 changes: 3 additions & 6 deletions nodeup/pkg/model/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/k8scodecs"
"k8s.io/kops/pkg/kubemanifest"
"k8s.io/kops/pkg/rbac"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/exec"
Expand Down Expand Up @@ -85,14 +86,10 @@ func (b *KubeControllerManagerBuilder) Build(c *fi.ModelBuilderContext) error {

// Add kubeconfig
{
// @TODO: Change kubeconfig to be https
kubeconfig, err := b.BuildPKIKubeconfig("kube-controller-manager")
if err != nil {
return err
}
kubeconfig := b.BuildIssuedKubeconfig("kube-controller-manager", nodetasks.PKIXName{CommonName: rbac.KubeControllerManager}, c)
c.AddTask(&nodetasks.File{
Path: "/var/lib/kube-controller-manager/kubeconfig",
Contents: fi.NewStringResource(kubeconfig),
Contents: kubeconfig,
Type: nodetasks.FileType_File,
Mode: s("0400"),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,31 @@ mode: "0600"
path: /srv/kubernetes/ca.key
type: file
---
contents: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMyRENDQWNDZ0F3SUJBZ0lSQUxKWEFrVmo5NjR0cTY3d01TSThvSlF3RFFZSktvWklodmNOQVFFTEJRQXcKRlRFVE1CRUdBMVVFQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpFeU1qY3lNelV5TkRCYUZ3MHlOekV5TWpjeQpNelV5TkRCYU1CVXhFekFSQmdOVkJBTV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c1BlaHFnaThlSXVxT0JraURXbVJ4QXhoCjh5R2VSeDlBYmtuSGg0SWEKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://127.0.0.1
name: local
contexts:
- context:
cluster: local
user: kube-controller-manager
name: service-account-context
current-context: service-account-context
kind: Config
users:
- name: kube-controller-manager
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMyRENDQWNDZ0F3SUJBZ0lSQUxKWEFrVmo5NjR0cTY3d01TSThvSlF3RFFZSktvWklodmNOQVFFTEJRQXcKRlRFVE1CRUdBMVVFQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpFeU1qY3lNelV5TkRCYUZ3MHlOekV5TWpjeQpNelV5TkRCYU1CVXhFekFSQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBCkE0SUJEd0F3Z2dFS0FvSUJBUURnbkNrU210bm1meEVnUzNxTlBhVUNINVFPQkdESC9pbkhiV0NPRExCQ0s5Z2QKWEVjQmw3RlZ2OFQya0ZyMURZYjBIVkR0TUk3dGl4UlZGRExna3dObFczNHh3V2RaWEI3R2VvRmdVMXhXT1FTWQpPQUNDOEpnWVRRLzEzOUhCRXZncTRzZWo2N3ArL3MvU05jdzM0S2s3SEl1RmhsazFyUms1a01leEtJbEpCS1AxCllZVVlldHNKL1FwVU9rcUo1SFc0R29ldEU3Nll0SG5PUmZZdm55YnZpU01yaDJ3R0dhTjZyL3M0Q2hPYUliWkMKQW44L1lpUEtHSURhWkdwajZHWG5tWEFSUlgvVElkZ1NRa0x3dDBhVERCblBaNFh2dHBJOGFhTDhEWUpJcUF6QQpOUEgyYjQvdU55bGF0NWpEbzBiMEc1NGFnTWk5NysyQVVyQzlVVVhwQWdNQkFBR2pJekFoTUE0R0ExVWREd0VCCi93UUVBd0lCQmpBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUEwR0NTcUdTSWIzRF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wS1M4M2c0SlF5bSswYUVmemgzNmJXY2wrdTZSNwpLaEtqKzlvU2Y5cG5kZ2szNDVnSnozNVJiUEpZaCtFdUFITnZ6ZGdDQXZLNngxakVUV2VLZjZidGo1cEYxVTFpClE0UU5Jdy9RaXdJWGpXWmV1YlRHc1FLQmdRQ2JkdUx1MnJMbmx5eUFhSlpNOERsSFp5SDJnQVhiQlpweHFVOFQKdDltdGtKRFVTL0tSaUVvWUdGVjlDcVMwYVhyYXlWTXNEZlhZNkIvUy9VdVpqTzV1N0x0a2xEenFPZjFhS0czUQpkR1hQS2lia25xcUpZSCtiblVOanVZWU5lckVUVjU3bGlqTUdIdVNZQ2Y4dndMbjNveEJmRVJSWDYxTS9EVThaCndvcnovUUtCZ1FEQ1RKSTIramRYZzI2WHVZVW1NNFhYZm5vY2Z6QVhoWEJVTHQxbkVOY29nTmYxZmNwdEFWdHUKQkFpejQvSGlwUUtxb1dWVVlteGZnYmJMUktLTEswczBsT1dLYllkVmpoRW0vbTJaVTh3dFhUYWdOd2tJR295cQpZL0MxTG94NGYxUk9KbkNqYy9oZmNPamN4WDVNOEE4cGVlY0hXbFZ0VVBLVEpneFE3b01LY3c9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
contents:
task:
CA:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Cert:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Key:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Name: kube-controller-manager
ServerURL: https://127.0.0.1
mode: "0400"
path: /var/lib/kube-controller-manager/kubeconfig
type: file
Expand All @@ -191,3 +197,33 @@ ifNotExists: true
mode: "0400"
path: /var/log/kube-controller-manager.log
type: file
---
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
---
CA:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Cert:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Key:
task:
Name: kube-controller-manager
signer: ca
subject:
CommonName: system:kube-controller-manager
type: client
Name: kube-controller-manager
ServerURL: https://127.0.0.1
11 changes: 0 additions & 11 deletions pkg/model/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@ func (b *PKIModelBuilder) Build(c *fi.ModelBuilderContext) error {
c.AddTask(t)
}

{
t := &fitasks.Keypair{
Name: fi.String("kube-controller-manager"),
Lifecycle: b.Lifecycle,
Subject: "cn=" + rbac.KubeControllerManager,
Type: "client",
Signer: defaultCA,
}
c.AddTask(t)
}

if b.UseEtcdManager() {
// We generate keypairs in the etcdmanager task itself
} else if b.UseEtcdTLS() {
Expand Down
1 change: 1 addition & 0 deletions upup/pkg/fi/nodeup/nodetasks/issue_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

// PKIXName is a simplified form of pkix.Name, for better golden test output
type PKIXName struct {
fi.NotADependency
CommonName string
}

Expand Down
7 changes: 4 additions & 3 deletions upup/pkg/fi/topological_sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ limitations under the License.
package fi

import (
"crypto/x509/pkix"
"fmt"
"reflect"

"k8s.io/klog"

"k8s.io/kops/util/pkg/reflectutils"
)

type HasDependencies interface {
GetDependencies(tasks map[string]Task) []Task
}

// NotADependency is a marker type to prevent FindTaskDependencies() from considering it a potential dependency.
type NotADependency struct{}

// FindTaskDependencies returns a map from each task's key to the discovered list of dependencies
func FindTaskDependencies(tasks map[string]Task) map[string][]string {
taskToId := make(map[interface{}]string)
Expand Down Expand Up @@ -107,7 +108,7 @@ func getDependencies(tasks map[string]Task, v reflect.Value) []Task {
// Ignore: not a dependency (?)
} else if _, ok := intf.(*ResourceHolder); ok {
// Ignore: not a dependency (?)
} else if _, ok := intf.(*pkix.Name); ok {
} else if _, ok := intf.(*NotADependency); ok {
// Ignore: not a dependency
} else {
return fmt.Errorf("Unhandled type for %q: %T", path, v.Interface())
Expand Down

0 comments on commit d604212

Please sign in to comment.