Build is responsible for generating the various pki assets.
(c *fi.CloudupModelBuilderContext)
| 33 | |
| 34 | // Build is responsible for generating the various pki assets. |
| 35 | func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { |
| 36 | // TODO: Only create the CA via this task |
| 37 | defaultCA := &fitasks.Keypair{ |
| 38 | Name: fi.PtrTo(fi.CertificateIDCA), |
| 39 | Lifecycle: b.Lifecycle, |
| 40 | Subject: "cn=kubernetes-ca", |
| 41 | Type: "ca", |
| 42 | } |
| 43 | c.AddTask(defaultCA) |
| 44 | |
| 45 | if b.Cluster.Spec.ServiceAccountIssuerDiscovery != nil && |
| 46 | b.Cluster.Spec.ServiceAccountIssuerDiscovery.DiscoveryService != nil && |
| 47 | b.Cluster.Spec.ServiceAccountIssuerDiscovery.DiscoveryService.URL != "" { |
| 48 | // TODO: Only create the discovery CA via this task (but it's tricky because we need the ID so early) |
| 49 | discoveryCA := &fitasks.Keypair{ |
| 50 | Name: fi.PtrTo(string(fi.DiscoveryCAID)), |
| 51 | Lifecycle: b.Lifecycle, |
| 52 | Subject: "cn=" + fi.DiscoveryCAID, |
| 53 | Type: "ca", |
| 54 | } |
| 55 | c.AddTask(discoveryCA) |
| 56 | } |
| 57 | |
| 58 | { |
| 59 | aggregatorCA := &fitasks.Keypair{ |
| 60 | Name: fi.PtrTo("apiserver-aggregator-ca"), |
| 61 | Lifecycle: b.Lifecycle, |
| 62 | Subject: "cn=apiserver-aggregator-ca", |
| 63 | Type: "ca", |
| 64 | } |
| 65 | c.AddTask(aggregatorCA) |
| 66 | } |
| 67 | |
| 68 | { |
| 69 | serviceAccount := &fitasks.Keypair{ |
| 70 | // We only need the private key, but it's easier to create a certificate as well. |
| 71 | Name: fi.PtrTo("service-account"), |
| 72 | Lifecycle: b.Lifecycle, |
| 73 | Subject: "cn=service-account", |
| 74 | Type: "ca", |
| 75 | } |
| 76 | c.AddTask(serviceAccount) |
| 77 | } |
| 78 | |
| 79 | // Create auth tokens (though this is deprecated) |
| 80 | for _, x := range tokens.GetKubernetesAuthTokens_Deprecated() { |
| 81 | c.AddTask(&fitasks.Secret{Name: fi.PtrTo(x), Lifecycle: b.Lifecycle}) |
| 82 | } |
| 83 | |
| 84 | { |
| 85 | mirrorPath, err := vfs.Context.BuildVfsPath(b.Cluster.Spec.ConfigStore.Secrets) |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | |
| 90 | t := &fitasks.MirrorSecrets{ |
| 91 | Name: fi.PtrTo("mirror-secrets"), |
| 92 | Lifecycle: b.Lifecycle, |
nothing calls this directly
no test coverage detected