Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backports: for 0.12.3 release #4296

Merged
merged 3 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (d *DHCP6) parseReply(reply *dhcpv6.Message) {
d.resolvers = nil
}

if len(reply.Options.FQDN().DomainName.Labels) > 0 {
if reply.Options.FQDN() != nil && len(reply.Options.FQDN().DomainName.Labels) > 0 {
d.hostname = []network.HostnameSpecSpec{
{
Hostname: reply.Options.FQDN().DomainName.Labels[0],
Expand Down
2 changes: 1 addition & 1 deletion internal/app/machined/pkg/controllers/secrets/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (ctrl *APIController) generateControlPlane(ctx context.Context, r controlle

func (ctrl *APIController) generateJoin(ctx context.Context, r controller.Runtime, logger *zap.Logger,
rootSpec *secrets.RootOSSpec, endpointsStr []string, ips []net.IP, dnsNames []string, fqdn string) error {
remoteGen, err := gen.NewRemoteGenerator(rootSpec.Token, endpointsStr)
remoteGen, err := gen.NewRemoteGenerator(rootSpec.Token, endpointsStr, rootSpec.CA)
if err != nil {
return fmt.Errorf("failed creating trustd client: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func SetupSharedFilesystems(seq runtime.Sequence, data interface{}) (runtime.Tas
// SetupVarDirectory represents the SetupVarDirectory task.
func SetupVarDirectory(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFunc, string) {
return func(ctx context.Context, logger *log.Logger, r runtime.Runtime) (err error) {
for _, p := range []string{"/var/log/pods", "/var/lib/kubelet", "/var/run/lock"} {
for _, p := range []string{"/var/log/containers", "/var/log/pods", "/var/lib/kubelet", "/var/run/lock"} {
if err = os.MkdirAll(p, 0o700); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions internal/app/machined/pkg/system/services/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (k *Kubelet) Runner(r runtime.Runtime) (runner.Runner, error) {
{Type: "bind", Destination: "/var/run", Source: "/run", Options: []string{"rbind", "rshared", "rw"}},
{Type: "bind", Destination: "/var/lib/containerd", Source: "/var/lib/containerd", Options: []string{"rbind", "rshared", "rw"}},
{Type: "bind", Destination: "/var/lib/kubelet", Source: "/var/lib/kubelet", Options: []string{"rbind", "rshared", "rw"}},
{Type: "bind", Destination: "/var/log/containers", Source: "/var/log/containers", Options: []string{"rbind", "rshared", "rw"}},
{Type: "bind", Destination: "/var/log/pods", Source: "/var/log/pods", Options: []string{"rbind", "rshared", "rw"}},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/grpc/gen/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ type RemoteGenerator struct {
}

// NewRemoteGenerator initializes a RemoteGenerator with a preconfigured grpc.ClientConn.
func NewRemoteGenerator(token string, endpoints []string) (g *RemoteGenerator, err error) {
func NewRemoteGenerator(token string, endpoints []string, ca *x509.PEMEncodedCertificateAndKey) (g *RemoteGenerator, err error) {
if len(endpoints) == 0 {
return nil, fmt.Errorf("at least one root of trust endpoint is required")
}

g = &RemoteGenerator{}

conn, err := basic.NewConnection(fmt.Sprintf("%s:///%s", trustdResolverScheme, strings.Join(endpoints, ",")), basic.NewTokenCredentials(token))
conn, err := basic.NewConnection(fmt.Sprintf("%s:///%s", trustdResolverScheme, strings.Join(endpoints, ",")), basic.NewTokenCredentials(token), ca)
if err != nil {
return nil, err
}
Expand Down
25 changes: 15 additions & 10 deletions pkg/grpc/middleware/auth/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package basic

import (
"crypto/tls"
stdx509 "crypto/x509"

"github.com/talos-systems/crypto/x509"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
Expand All @@ -20,17 +22,20 @@ type Credentials interface {

// NewConnection initializes a grpc.ClientConn configured for basic
// authentication.
func NewConnection(address string, creds credentials.PerRPCCredentials) (conn *grpc.ClientConn, err error) {
grpcOpts := []grpc.DialOption{}

grpcOpts = append(
grpcOpts,
grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
InsecureSkipVerify: true,
})),
func NewConnection(address string, creds credentials.PerRPCCredentials, ca *x509.PEMEncodedCertificateAndKey) (conn *grpc.ClientConn, err error) {
tlsConfig := &tls.Config{}

if ca == nil {
tlsConfig.InsecureSkipVerify = true
} else {
tlsConfig.RootCAs = stdx509.NewCertPool()
tlsConfig.RootCAs.AppendCertsFromPEM(ca.Crt)
}

grpcOpts := []grpc.DialOption{
grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)),
grpc.WithPerRPCCredentials(creds),
)
}

conn, err = grpc.Dial(address, grpcOpts...)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/machinery/config/types/v1alpha1/generate/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func workerUd(in *Input) (*v1alpha1.Config, error) {
KubeletImage: emptyIf(fmt.Sprintf("%s:v%s", constants.KubeletImage, in.KubernetesVersion), in.KubernetesVersion),
},
MachineNetwork: networkConfig,
MachineCA: &x509.PEMEncodedCertificateAndKey{Crt: in.Certs.OS.Crt},
MachineInstall: &v1alpha1.InstallConfig{
InstallDisk: in.InstallDisk,
InstallImage: in.InstallImage,
Expand Down