generated from nginx/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Checkpoint - DEMO - DEMO - Implements Certificates - Certificates fleshed out and tests underway - Refactoring of authorization tests required due to changes in the shape of the Certificates module. - FRT (Fix Red Tests) - minor cleanup - Base implementation of Certificate and informer - authentication factory implemented - rename, and doc start - CHECKPOINT: File creation
- Loading branch information
Showing
42 changed files
with
1,932 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,7 @@ Thumbs.db | |
######## | ||
*.log | ||
/misc-dev/ | ||
|
||
cover* | ||
tmp/ | ||
docs/tls/DESIGN.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
data: | ||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURUekNDQWpjQ0ZGNGlKWWxnWFYrNksxclE0L1JacXEyTWxRTWZNQTBHQ1NxR1NJYjNEUUVCQ3dVQU1HUXgKQ3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRSURBcFhZWE5vYVc1bmRHOXVNUkF3RGdZRFZRUUhEQWRUWldGMApkR3hsTVE0d0RBWURWUVFLREFWT1IwbE9XREVlTUJ3R0ExVUVDd3dWUTI5dGJYVnVhWFI1SUNZZ1FXeHNhV0Z1ClkyVnpNQjRYRFRJek1UQXdNakl6TURReU9Wb1hEVEl6TVRFd01USXpNRFF5T1Zvd1pERUxNQWtHQTFVRUJoTUMKVlZNeEV6QVJCZ05WQkFnTUNsZGhjMmhwYm1kMGIyNHhFREFPQmdOVkJBY01C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W1xVVRvTGE3T3FFeHpiRmFCUnMwQ2dZQUN6UlBiQTBqK0JyOWpxenFKYU56VQpPZzJ4aUFhZlNuTzBxTkREZWZNdXhZSnFMZ0llMG9HRUExb1JlcDhvTDNDeWZYd2h3U2xqMlRjeGZZTFR5MENKCmZBejF4QjY3SUF3cGlvZnI0K1ZXekF4SC9BbnlhVGNZVGdtakdKdlhtZ3l1RGU3ZGJsa3lJU1M5ZTBLc1JzeTYKQ2hPdVZoQy96bjErbm9BMkNsdzFJdz09Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K | ||
kind: Secret | ||
metadata: | ||
creationTimestamp: null | ||
name: nlk-tls-ca-secret | ||
namespace: nlk | ||
type: kubernetes.io/tls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
data: | ||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVIRENDQXdTZ0F3SUJBZ0lVUFRrVExlS3FNQlRlNFZhQXpiL1hXcSt6THM4d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pERUxNQWtHQTFVRUJoTUNWVk14RXpBUkJnTlZCQWdNQ2xkaGMyaHBibWQwYjI0eEVEQU9CZ05WQkFjTQpCMU5sWVhSMGJHVXhEakFNQmdOVkJBb01CVTVIU1U1WU1SNHdIQVlEVlFRTERCVkRiMjF0ZFc1cGRIa2dKaUJCCmJHeHBZVzVqWlhNd0hoY05Nak14TURBeU1qTXdOak0zV2hjTk1qUXhNREF4TWpNd05qTTNXakJrTVFzd0NRWUQKVlFRR0V3SlZVekVUTUJFR0ExVUVDQXdLVjJGemFHbHVaM1J2YmpFUU1BNEdBMVVFQnd3SFUyVmhkSFJzWlRFTwpNQXdHQTFVRUNnd0ZUa2RKVGxneEhqQWNCZ05WQkFzTU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zVxSGR2a3VnblRwYzROcHREU0tDczZuYUdHTG9CNlhMMHh2U1l3UStxQTR0RU0rQkxIVmE5cUJBb0dCQUk1NApXYzlsb2lvZnM4SS85cDBxSHpuS1d3RWFWMVVMNmdRN1hiaXNmQzk5OVNQUzFsNktLMmJMdThjUzErV0JMczdvClBSL0JZMnYzbExyd1JSb1NJMm1jaUFkaUhGdWUxa0JNL2p6L0c0WlFZNSt4VEdSRXVLUUtQeWd0ZEVGQktxcFIKUkowQ0taR01uUkYreFRkNGFkS2I2OUlVZWwwdElBU25xMm1yaXFJTkFvR0FKcmtDS2Rxejg5blRYd3FnbmZrWgpSbVB5Tk1sMjlidDNIT1ZsR3ZoTjJib3lBeHFaYk4xLzdaWE5OSlFKR3J0TUx0QzFXY3o1bXE0czY1QW5KSFhaCkhQWVRyWGdmdjc2SHROMG95TDcxbFBUOTZpU3RHc0tWSmx1R1MvT3I2TXh2Nm5XTEY0aG1mUURqaGpSNVgvdEsKTW1XV0J5Q2JRTU9mRm5hRjB2azJuTXM9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K | ||
kind: Secret | ||
metadata: | ||
creationTimestamp: null | ||
name: nlk-tls-client-secret | ||
namespace: nlk | ||
type: kubernetes.io/tls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2023 F5 Inc. All rights reserved. | ||
* Use of this source code is governed by the Apache License that can be found in the LICENSE file. | ||
*/ | ||
|
||
/* | ||
Package certificates_test_harness includes functionality boostrap and test the certification.Certificates implplementation. | ||
*/ | ||
|
||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"github.com/nginxinc/kubernetes-nginx-ingress/internal/certification" | ||
"github.com/sirupsen/logrus" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"k8s.io/client-go/util/homedir" | ||
"path/filepath" | ||
) | ||
|
||
func main() { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
err := run() | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} | ||
|
||
func run() error { | ||
logrus.Info("certificates-test-harness::run") | ||
|
||
ctx := context.Background() | ||
var err error | ||
|
||
k8sClient, err := buildKubernetesClient() | ||
if err != nil { | ||
return fmt.Errorf(`error building a Kubernetes client: %w`, err) | ||
} | ||
|
||
certificates, err := certification.NewCertificates(ctx, k8sClient) | ||
if err != nil { | ||
return fmt.Errorf(`error occurred creating certificates: %w`, err) | ||
} | ||
|
||
err = certificates.Initialize() | ||
if err != nil { | ||
return fmt.Errorf(`error occurred initializing certificates: %w`, err) | ||
} | ||
|
||
go certificates.Run() | ||
|
||
<-ctx.Done() | ||
return nil | ||
} | ||
|
||
func buildKubernetesClient() (*kubernetes.Clientset, error) { | ||
logrus.Debug("Watcher::buildKubernetesClient") | ||
|
||
var kubeconfig *string | ||
var k8sConfig *rest.Config | ||
|
||
k8sConfig, err := rest.InClusterConfig() | ||
if errors.Is(err, rest.ErrNotInCluster) { | ||
if home := homedir.HomeDir(); home != "" { | ||
path := filepath.Join(home, ".kube", "config") | ||
kubeconfig = &path | ||
|
||
k8sConfig, err = clientcmd.BuildConfigFromFlags("", *kubeconfig) | ||
if err != nil { | ||
return nil, fmt.Errorf(`error occurred building the kubeconfig: %w`, err) | ||
} | ||
} else { | ||
return nil, fmt.Errorf(`not running in a Cluster: %w`, err) | ||
} | ||
} else if err != nil { | ||
return nil, fmt.Errorf(`error occurred getting the Cluster config: %w`, err) | ||
} | ||
|
||
client, err := kubernetes.NewForConfig(k8sConfig) | ||
if err != nil { | ||
return nil, fmt.Errorf(`error occurred creating a client: %w`, err) | ||
} | ||
return client, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
configuration2 "github.com/nginxinc/kubernetes-nginx-ingress/internal/configuration" | ||
"github.com/sirupsen/logrus" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"k8s.io/client-go/util/homedir" | ||
"path/filepath" | ||
) | ||
|
||
func main() { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
err := run() | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} | ||
|
||
func run() error { | ||
logrus.Info("configuration-test-harness::run") | ||
|
||
ctx := context.Background() | ||
var err error | ||
|
||
k8sClient, err := buildKubernetesClient() | ||
if err != nil { | ||
return fmt.Errorf(`error building a Kubernetes client: %w`, err) | ||
} | ||
|
||
configuration, err := configuration2.NewSettings(ctx, k8sClient) | ||
if err != nil { | ||
return fmt.Errorf(`error occurred creating configuration: %w`, err) | ||
} | ||
|
||
err = configuration.Initialize() | ||
if err != nil { | ||
return fmt.Errorf(`error occurred initializing configuration: %w`, err) | ||
} | ||
|
||
go configuration.Run() | ||
|
||
<-ctx.Done() | ||
|
||
return err | ||
} | ||
|
||
func buildKubernetesClient() (*kubernetes.Clientset, error) { | ||
logrus.Debug("Watcher::buildKubernetesClient") | ||
|
||
var kubeconfig *string | ||
var k8sConfig *rest.Config | ||
|
||
k8sConfig, err := rest.InClusterConfig() | ||
if errors.Is(err, rest.ErrNotInCluster) { | ||
if home := homedir.HomeDir(); home != "" { | ||
path := filepath.Join(home, ".kube", "config") | ||
kubeconfig = &path | ||
|
||
k8sConfig, err = clientcmd.BuildConfigFromFlags("", *kubeconfig) | ||
if err != nil { | ||
return nil, fmt.Errorf(`error occurred building the kubeconfig: %w`, err) | ||
} | ||
} else { | ||
return nil, fmt.Errorf(`not running in a Cluster: %w`, err) | ||
} | ||
} else if err != nil { | ||
return nil, fmt.Errorf(`error occurred getting the Cluster config: %w`, err) | ||
} | ||
|
||
client, err := kubernetes.NewForConfig(k8sConfig) | ||
if err != nil { | ||
return nil, fmt.Errorf(`error occurred creating a client: %w`, err) | ||
} | ||
return client, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package main |
Oops, something went wrong.