-
Notifications
You must be signed in to change notification settings - Fork 741
Conversation
also tear down backup replicaset before etcd pods. fixes #216
only support self-signed mode for now, appropriate hook in place for remote signing complete with todo's. This will involve exchanging a CSR for a Certificate via the Kubernetes API, allowing the delegating CA's private key material to remain private.
fixes #12 |
) | ||
|
||
// Parse from file if exists, else create new and write to file | ||
func InitializePrivateKeyFile(keyPath string) (*rsa.PrivateKey, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called "InitializePrivateKeyFile"? Is it gonna initialize private key or initialize a file?
return rsa.GenerateKey(rand.Reader, RSAKeySize) | ||
} | ||
|
||
func writePrivateKeyToFile(keyPath string, key *rsa.PrivateKey) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two funcs aren't used in this file. Could you move them to where they are used?
@colhom |
@@ -16,17 +17,26 @@ var ( | |||
func init() { | |||
flag.StringVar(&cfg.PVProvisioner, "pv-provisioner", "kubernetes.io/gce-pd", "persistent volume provisioner type") | |||
flag.BoolVar(&analyticsEnabled, "analytics", true, "Send analytical event (Cluster Created/Deleted etc.) to Google Analytics") | |||
flag.StringVar(&cfg.EtcdTLSConfig.Dir, "etcd-tls-dir", "/etc/kube-etcd-controller/tls/", "directory to store etcd tls files. in most cases, this path will be mounted in a secret.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move these under "masterhost" flag?
It'd better group all TLS flags together, and more specifically all etcd TLS together
flag.Parse() | ||
|
||
cfg.Namespace = os.Getenv("MY_POD_NAMESPACE") | ||
if len(cfg.Namespace) == 0 { | ||
cfg.Namespace = "default" | ||
} | ||
if err := os.MkdirAll(cfg.EtcdTLSConfig.Dir, 0600); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we create the dir?
Why not let user create the dir because they pass in.
idCounter int | ||
eventCh chan *clusterEvent | ||
stopCh chan struct{} | ||
kclient *unversioned.Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't group them together.
And group ca stuff together.
} | ||
} | ||
|
||
func (c *Controller) initializeClusterTLS(clusterName string, clusterSpec *spec.ClusterSpec) (*rsa.PrivateKey, *x509.Certificate, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put TLS methods into another file "controller/tls.go"?
@@ -40,6 +42,16 @@ type ClusterSpec struct { | |||
// If there is no seed member, a completely new cluster will be created. | |||
// There is no seed member by default. | |||
Seed *SeedPolicy `json:"seed,omitempty"` | |||
// Common name for the cluster CA | |||
// Defaults to the cluster name | |||
CACommonName string `json:"caCommonName,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you abstract another struct "TLSPolicy"?
@hongchaodeng I'm going to pause on this implementation and produce a design document before continuing (as you suggest). A few of your questions on this PR will hopefully be answered by the design doc. |
@colhom Thanks! |
Any update on this? |
The first commit is from #217, disregard for this review.
Here is the overview for kube-etcd-controller TLS flow, which should set us up well for integrating with pre-existing external PKI.
Trust delegation model:
Here are the steps in order:
controller CA
private keycontroller CA
certificatecontroller CA
as a subordinate CA ofcluster CA
using parameter from cluster specCN=etcd-cluster-xxxx
, submit for signing via annotationpod/etcd-cluster-xxxx
cluster CA
forpod/etcd-cluster-xxxx
pod/etcd-cluster-xxxx
pod/etcd-cluster-xxxx
cluster CA
certificateSo far I have implemented up through step 2
\cc @hongchaodeng @brianredbeard