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

Adding TLS configuration for fn-runner image registries #139

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Catalin-Stratulat-Ericsson
Copy link
Contributor

@Catalin-Stratulat-Ericsson Catalin-Stratulat-Ericsson commented Nov 13, 2024

Tackles issue #819.

Adds the ability to utilize a user's TLS certificates in the function runner for interacting with private TLS registries.

Documentation for how to configure the function runner in this way can be found PR#183.

Copy link
Contributor

nephio-prow bot commented Nov 13, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Catalin-Stratulat-Ericsson
Once this PR has been reviewed and has the lgtm label, please assign liamfallon for approval by writing /assign @liamfallon in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Catalin-Stratulat-Ericsson
Copy link
Contributor Author

/test presubmit-nephio-go-test

@@ -28,6 +31,7 @@ import (

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have a more distinctive alias? Something like

Suggested change
v1 "github.com/google/go-containerregistry/pkg/v1"
containerregistry "github.com/google/go-containerregistry/pkg/v1"

@@ -597,9 +619,70 @@ func (pm *podManager) getCustomAuth(ref name.Reference, registryAuthSecretPath s
return authn.FromConfig(dockerConfig.Auths[ref.Context().RegistryStr()]), nil
}

func loadTLSConfig(caCertPath string) (*tls.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving these new methods to be more in the order they're used in - so:

  • getImageMetadata
  • getImage
  • loadTLSConfig
  • createTransport

// Append the CA certificate to the system pool
caCertPool := x509.NewCertPool()
if !caCertPool.AppendCertsFromPEM(caCert) {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't err still be nil in this case? Should we create a new error to return instead?

return nil, err
}
if _, err := os.Stat(filepath.Join(tlsSecretPath, "ca.crt")); os.IsNotExist(err) {
klog.Error(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this log be inside the check-for-ca.pem if block, to indicate that we couldn't find a ca file with either extension?
(or perhaps make this one a Warn and add an Error in the .pem check?)

Comment on lines +650 to +653
_, err := os.Stat(tlsSecretPath)
if os.IsNotExist(err) {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined check syntax?

Suggested change
_, err := os.Stat(tlsSecretPath)
if os.IsNotExist(err) {
return nil, err
}
if _, err := os.Stat(tlsSecretPath); os.IsNotExist(err) {
return nil, err
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants