From 58bb6dec06b8bc260dde625333f5527e4b39e74f Mon Sep 17 00:00:00 2001 From: efiacor Date: Fri, 16 Feb 2024 11:14:55 +0000 Subject: [PATCH 1/9] Update guides to refer to release artefacts --- docs/development.md | 1 + docs/porchctl-cli-guide.md | 37 +++++++++++++++---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/docs/development.md b/docs/development.md index c89d367a..f3117e13 100644 --- a/docs/development.md +++ b/docs/development.md @@ -13,6 +13,7 @@ make generate Porch comprises of several software components: * [api](../api): Definition of the KRM API supported by the Porch extension apiserver +* [porchctl](../cmd/porchctl): CLI command tool for administration of Porch `Repository` and `PackageRevision` custom resources. * [apiserver](../pkg/apiserver/): The Porch apiserver implementation, REST handlers, Porch `main` function * [engine](../pkg/engine/): Core logic of Package Orchestration - operations on package contents * [func](../func): KRM function evaluator microservice; exposes gRPC API diff --git a/docs/porchctl-cli-guide.md b/docs/porchctl-cli-guide.md index f3326149..dab8272e 100644 --- a/docs/porchctl-cli-guide.md +++ b/docs/porchctl-cli-guide.md @@ -1,18 +1,26 @@ ## Using the porchctl cli -When Porch was ported to Nephio, the `kpt alpha rpkg` commands in kpt were moved into a new command called `porchctl`. Porch is as yet not released in Nephio, so we need to build the `porchctl` command from source. +When Porch was ported to Nephio, the `kpt alpha rpkg` commands in kpt were moved into a new command called `porchctl`. +See the [project releases](https://github.com/nephio-project/porch/releases) for information on the latest release. + +Once the preferred binary is downloaded and extracted, we can set it up for use locally. + +_optional: Configure `porchctl` on your environment_ + +1. Either add `porchctl` to your PATH or copy it to a directory already in the path. +``` +cp porchctl /usr/local/bin/ ``` -git clone https://github.com/nephio-project/porch.git -cd porch -go build -o build/porchctl ./cmd/porchctl +2. Generate the autocompletion script for the specified shell to add to your profile. +``` +porchctl completion bash ``` -
-Check that porchctl is working: +Check that porchctl is working: ``` -build/porchctl --help +porchctl --help porchctl interacts with a Kubernetes API server with the Porch server installed as an aggregated API server. It allows you to @@ -39,21 +47,6 @@ Flags: Use "porchctl [command] --help" for more information about a command. ``` -
- - - -_optional: Configure `porchctl` on your environment_ - -1. Either add `porchctl` to your PATH or copy it to a directory already in the path -``` -sudo cp build/porchctl /usr/local/bin/ -``` -2. Generate the autocompletion script for the specified shell to add to your profile. -``` -porchctl completion bash -``` - The `porchtcl` command is an administration command for acting on Porch `Repository` (repo) and `PackageRevision` (rpkg) CRs. From 5d56bdf421e6d3cad3cdd4e9a97ab204e2731733 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 28 Feb 2024 16:44:27 +0000 Subject: [PATCH 2/9] Allow porch namespace in cert/webhook to be configured --- pkg/apiserver/apiserver.go | 10 ++++++++-- pkg/apiserver/webhooks.go | 20 ++++++++++---------- pkg/apiserver/webhooks_test.go | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 73cfac4b..3af6bc84 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "os" + "strings" "time" "github.com/nephio-project/porch/api/porch/install" @@ -281,9 +282,14 @@ func (c completedConfig) New() (*PorchServer, error) { func (s *PorchServer) Run(ctx context.Context) error { porch.RunBackground(ctx, s.coreClient, s.cache) + webhookNs, found := os.LookupEnv("CERT_NAMESPACE") + if !found || strings.TrimSpace(webhookNs) == "" { + webhookNs = "porch-system" + } + certStorageDir, found := os.LookupEnv("CERT_STORAGE_DIR") - if found && certStorageDir != "" { - if err := setupWebhooks(ctx, certStorageDir); err != nil { + if found && strings.TrimSpace(certStorageDir) != "" { + if err := setupWebhooks(ctx, webhookNs, certStorageDir); err != nil { klog.Errorf("%v\n", err) return err } diff --git a/pkg/apiserver/webhooks.go b/pkg/apiserver/webhooks.go index 8196ec3f..48ecc0d5 100644 --- a/pkg/apiserver/webhooks.go +++ b/pkg/apiserver/webhooks.go @@ -51,12 +51,12 @@ const ( serverEndpoint = "/validate-deletion" ) -func setupWebhooks(ctx context.Context, certStorageDir string) error { - caBytes, err := createCerts(certStorageDir) +func setupWebhooks(ctx context.Context, webhookNs string, certStorageDir string) error { + caBytes, err := createCerts(webhookNs, certStorageDir) if err != nil { return err } - if err := createValidatingWebhook(ctx, caBytes); err != nil { + if err := createValidatingWebhook(ctx, webhookNs, caBytes); err != nil { return err } if err := runWebhookServer(certStorageDir); err != nil { @@ -65,11 +65,11 @@ func setupWebhooks(ctx context.Context, certStorageDir string) error { return nil } -func createCerts(certStorageDir string) ([]byte, error) { - klog.Infoln("creating self-signing TLS cert and key ") +func createCerts(webhookNs string, certStorageDir string) ([]byte, error) { + klog.Infoln("creating self-signing TLS cert and key with namespace " + webhookNs + " in directory " + certStorageDir) dnsNames := []string{"api", - "api.porch-system", "api.porch-system.svc"} - commonName := "api.porch-system.svc" + "api." + webhookNs, "api." + webhookNs + ".svc"} + commonName := "api." + webhookNs + ".svc" var caPEM, serverCertPEM, serverPrivateKeyPEM *bytes.Buffer // CA config @@ -165,8 +165,8 @@ func WriteFile(filepath string, c []byte) error { return nil } -func createValidatingWebhook(ctx context.Context, caCert []byte) error { - klog.Infoln("Creating validating webhook") +func createValidatingWebhook(ctx context.Context, webhookNs string, caCert []byte) error { + klog.Infoln("Creating validating webhook with namespace " + webhookNs) cfg := ctrl.GetConfigOrDie() kubeClient, err := kubernetes.NewForConfig(cfg) @@ -175,7 +175,7 @@ func createValidatingWebhook(ctx context.Context, caCert []byte) error { } var ( - webhookNamespace = "porch-system" + webhookNamespace = webhookNs validationCfgName = "packagerev-deletion-validating-webhook" webhookService = "api" path = serverEndpoint diff --git a/pkg/apiserver/webhooks_test.go b/pkg/apiserver/webhooks_test.go index 9a24c9ca..5223148d 100644 --- a/pkg/apiserver/webhooks_test.go +++ b/pkg/apiserver/webhooks_test.go @@ -36,7 +36,7 @@ func TestCreateCerts(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - caCert, err := createCerts(dir) + caCert, err := createCerts("", dir) require.NoError(t, err) caStr := strings.TrimSpace(string(caCert)) From 5ce3d0d7ffd44e3e98fd6d4d7efd7eb7066d83ba Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 1 Mar 2024 10:08:07 +0000 Subject: [PATCH 3/9] Updated date on copyright notices --- pkg/apiserver/apiserver.go | 2 +- pkg/apiserver/webhooks.go | 2 +- pkg/apiserver/webhooks_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 3af6bc84..31e54eda 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -1,4 +1,4 @@ -// Copyright 2022 The kpt and Nephio Authors +// Copyright 2022,2024 The kpt and Nephio Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/apiserver/webhooks.go b/pkg/apiserver/webhooks.go index 48ecc0d5..934b20ef 100644 --- a/pkg/apiserver/webhooks.go +++ b/pkg/apiserver/webhooks.go @@ -1,4 +1,4 @@ -// Copyright 2022 The kpt and Nephio Authors +// Copyright 2022,2024 The kpt and Nephio Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/apiserver/webhooks_test.go b/pkg/apiserver/webhooks_test.go index 5223148d..84aad665 100644 --- a/pkg/apiserver/webhooks_test.go +++ b/pkg/apiserver/webhooks_test.go @@ -1,4 +1,4 @@ -// Copyright 2022 The kpt and Nephio Authors +// Copyright 2022,2024 The kpt and Nephio Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From f6fb29f9b09a58c6c9df2a4d3a6c8e90a23e7c8c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 26 Feb 2024 12:59:18 +0000 Subject: [PATCH 4/9] Tutorial showing how to set up a local Porch server towards a Kind cluster --- .../porch-development-environment/README.md | 151 ++++++++++++++++++ .../bin/cleardown.sh | 7 + .../bin/setup.sh | 90 +++++++++++ docs/tutorials/starting-with-porch/README.md | 2 +- 4 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 docs/tutorials/porch-development-environment/README.md create mode 100755 docs/tutorials/porch-development-environment/bin/cleardown.sh create mode 100755 docs/tutorials/porch-development-environment/bin/setup.sh diff --git a/docs/tutorials/porch-development-environment/README.md b/docs/tutorials/porch-development-environment/README.md new file mode 100644 index 00000000..1cf246ac --- /dev/null +++ b/docs/tutorials/porch-development-environment/README.md @@ -0,0 +1,151 @@ +# Setting up a development environment for Porch + +This tutorial gives short instructions on how to set up a development environment for Porch. It outlines the steps to get a [kind](https://kind.sigs.k8s.io/) cluster up +and running to which a Porch instance running in Visual Studio Code can connect to and interact with. + +# Setup kind with MetalLB and Gitea + +Follow steps 1-5 inclusive of the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch) tutorial. You now have 2 Kind clusters +running with Gitea installed. Gitea has the repositories `management` and `edge1` defined. + +> **_NOTE:_** The [setup script](bin/setup.sh) automates steps 1-5 of the Starting with Porch tutorial. You may need to adaot this script to your local environment. + +> **_NOTE:_** The [cleardown script script](bin/cleardown.sh) clears everything down by deleting the `management` and `edge1` Kind clusters. USE WITH CARE. + + +You can reach the Gitea web interface on the address reported byt he following command: +``` +kubectl get svc -n gitea gitea +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +gitea LoadBalancer 10.197.10.118 172.18.255.200 22:31260/TCP,3000:31012/TCP 8m35s +``` + +# Install the Porch function runner + +The Porch server requires that the Porch function runner is executing. To install the Porch function runner on the Kind management cluster, execute the following commands. + +``` +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/0-packagerevs.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/0-packagevariants.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/0-packagevariantsets.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/0-repositories.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/1-namespace.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/catalog/main/nephio/core/porch/2-function-runner.yaml + +kubectl wait --namespace porch-system \ + --for=condition=ready pod \ + --selector=app=function-runner \ + --timeout=300s +``` + +The Porch function runner should now be executing + +``` +kubectl get pod -n porch-system --selector=app=function-runner +NAME READY STATUS RESTARTS AGE +function-runner-67d4c7c7b-7wm97 1/1 Running 0 16m +function-runner-67d4c7c7b-czvvq 1/1 Running 0 16m +``` + +Expose the `function-runner` service so that the Porch server running in Visual Studio Code can reach it, change the service type from `ClusterIP` to `LoadBalancer`: + +``` +kubectl edit svc -n porch-system function-runner + +31c31 +< type: ClusterIP +--- +> type: LoadBalancer +``` + +Now check that the `function-runner` service has been assigned an IP address external to the cluster: +``` +kubectl get svc -n porch-system function-runner +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +function-runner LoadBalancer 10.197.168.148 172.18.255.201 9445:31794/TCP 22m +``` + +# Install Porch resources for standalone execution + +The Porch server requires that the following resources are defined int he K8S cluster where it is executed: + +- The `porch-system` namespace, an API Service called `apiservice.apiregistration.k8s.io/v1alpha1.porch.kpt.dev` and the `service.api` service to expose the API Service. These resources are defined in the the file `deployments/local/localconfig.yaml` +- the `repositories.config.porch.kpt.dev` and `functions.config.porch.kpt.dev` CRDs. These CRDs are defined in the `api/porchconfig/v1alpha1/` directory. +- the `packagerevs.config.porch.kpt.dev` CRD. This CRD is defined in the `internal/api/porchinternal/v1alpha1/` directory. +- + +``` +kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/deployments/local/localconfig.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/api/porchconfig/v1alpha1/config.porch.kpt.dev_repositories.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/api/porchconfig/v1alpha1/config.porch.kpt.dev_functions.yaml +kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/internal/api/porchinternal/v1alpha1/config.porch.kpt.dev_packagerevs.yaml +``` +Verify that the resources have been created +``` +kubectl api-resources | grep -i porch +functions config.porch.kpt.dev/v1alpha1 true Function +packagerevs config.porch.kpt.dev/v1alpha1 true PackageRev +packagevariants config.porch.kpt.dev/v1alpha1 true PackageVariant +packagevariantsets config.porch.kpt.dev/v1alpha2 true PackageVariantSet +repositories config.porch.kpt.dev/v1alpha1 true Repository +``` + +# Configure VSCode to run the Porch server + +Check out porch and start vscode in the root of your checked out Porch repo. + +Edit your local `.vscode.launch.json` file as follows: +1. Change the `--kubeconfig` value to point at your local Kind cluster configuration file +2. Change the `--function-runner` IP address to that of the function runner service running in the Kind `management` cluster + +``` + { + "name": "Launch Server", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/cmd/porch/main.go", + "args": [ + "--secure-port=9443", + "--v=7", + "--standalone-debug-mode", + "--kubeconfig=/home/sean-citizen/.kube/kind-management-config", + "--cache-directory=${workspaceFolder}/.cache", + "--function-runner=172.18.255.201:9445" + ], + "env": { + "KUBECONFIG": "/Users/liam/.kube/kind-management-config" + }, + "cwd": "${workspaceFolder}" + }, +``` + +You can now launch the Porch server locally in VSCode by selecting the "Launch Server" configuration on the VSCode "Run and Debug" window. + +# Create Repositories using your local Porch server + +Follow step 6 to connect Gitea to Porch in the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch#connect-the-gitea-repositories-to-porch) tutorial to create the Gitea and external repositories in Porch. + +You will notice logging messages in VSCode when you run the command `kubectl apply -f porch-repositories.yaml` command. + +You can check that your locally running Porch server has created the repositories by running the `porchctl` command. + +``` +porchctl repo get -A +NAME TYPE CONTENT DEPLOYMENT READY ADDRESS +edge1 git Package true True http://172.18.255.200:3000/nephio/edge1.git +external-blueprints git Package false True https://github.com/nephio-project/free5gc-packages.git +management git Package false True http://172.18.255.200:3000/nephio/management.git +``` + +You can also check the repositories using kubectl. + +``` +kubectl get repositories -n porch-demo +NAME TYPE CONTENT DEPLOYMENT READY ADDRESS +edge1 git Package true True http://172.18.255.200:3000/nephio/edge1.git +external-blueprints git Package false True https://github.com/nephio-project/free5gc-packages.git +management git Package false True http://172.18.255.200:3000/nephio/management.git +``` + +You now have a locally running Porch server. Happy developing! \ No newline at end of file diff --git a/docs/tutorials/porch-development-environment/bin/cleardown.sh b/docs/tutorials/porch-development-environment/bin/cleardown.sh new file mode 100755 index 00000000..2606074d --- /dev/null +++ b/docs/tutorials/porch-development-environment/bin/cleardown.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +kind delete cluster --name management +kind delete cluster --name edge1 + +rm ~/.kube/kind-management-config +rm ~/.kube/kind-edge1-config \ No newline at end of file diff --git a/docs/tutorials/porch-development-environment/bin/setup.sh b/docs/tutorials/porch-development-environment/bin/setup.sh new file mode 100755 index 00000000..371ce238 --- /dev/null +++ b/docs/tutorials/porch-development-environment/bin/setup.sh @@ -0,0 +1,90 @@ +#! /bin/bash + +os_type=$(uname) +if [ "$os_type" = "Darwin" ] +then + SED="gsed" +else + SED="sed" +fi + +# Create mgmt and edge1 clusters in kind +curl -s https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/kind_management_cluster.yaml | \ + kind create cluster --config=- + +curl -s https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/kind_edge1_cluster.yaml | \ + kind create cluster --config=- + +kind get kubeconfig --name=management > ~/.kube/kind-management-config +kind get kubeconfig --name=edge1 > ~/.kube/kind-edge1-config + +export KUBECONFIG=~/.kube/kind-management-config + +# Instal MetalLB +kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml +kubectl wait --namespace metallb-system \ + --for=condition=ready pod \ + --selector=component=controller \ + --timeout=90s + +kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/docs/tutorials/starting-with-porch/metallb-conf.yaml + +TMP_DIR=$(mktemp -d) + +pushd "$TMP_DIR" || exit + +mkdir kpt_packages +pushd kpt_packages || exit + +# Install Gitea +kpt pkg get https://github.com/nephio-project/catalog/tree/main/distros/sandbox/gitea +$SED -i 's/ metallb.universe.tf/ #metallb.universe.tf/' gitea/service-gitea.yaml +kpt fn render gitea +kpt live init gitea +kpt live apply gitea + +popd || exit + +# Create management and edge1 repos in gitea +curl -k -H "content-type: application/json" "http://nephio:secret@172.18.255.200:3000/api/v1/user/repos" --data '{"name":"management"}' +curl -k -H "content-type: application/json" "http://nephio:secret@172.18.255.200:3000/api/v1/user/repos" --data '{"name":"edge1"}' + +mkdir repos +pushd repos || exit + +# Initialize management and edge1 repos in Gitea +git clone http://172.18.255.200:3000/nephio/management +pushd management || exit + +touch README.md +git init +git checkout -b main +git config user.name nephio +git add README.md + +git commit -m "first commit" +git remote remove origin +git remote add origin http://nephio:secret@172.18.255.200:3000/nephio/management.git +git remote -v +git push -u origin main +popd || exit + +git clone http://172.18.255.200:3000/nephio/edge1 +pushd edge1 || exit + +touch README.md +git init +git checkout -b main +git config user.name nephio +git add README.md + +git commit -m "first commit" +git remote remove origin +git remote add origin http://nephio:secret@172.18.255.200:3000/nephio/edge1.git +git remote -v +git push -u origin main +popd || exit + +popd || exit + +rm -fr "$TMP_DIR" diff --git a/docs/tutorials/starting-with-porch/README.md b/docs/tutorials/starting-with-porch/README.md index a0109b59..b001efc7 100644 --- a/docs/tutorials/starting-with-porch/README.md +++ b/docs/tutorials/starting-with-porch/README.md @@ -1,4 +1,4 @@ -# Porch Tutorial +# Starting with Porch Tutorial This tutorial is a guide to installing and using Porch. It is based on the [Porch demo produced by Tal Liron of Google](https://github.com/tliron/klab/tree/main/environments/porch-demo). Users should be very comfortable with using with `git`, `docker`, and `kubernetes`. From 813580d2953c1505c65ccc668f3905c9198724d8 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 26 Feb 2024 13:08:27 +0000 Subject: [PATCH 5/9] Fixed typos --- .../porch-development-environment/README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/porch-development-environment/README.md b/docs/tutorials/porch-development-environment/README.md index 1cf246ac..860f0e64 100644 --- a/docs/tutorials/porch-development-environment/README.md +++ b/docs/tutorials/porch-development-environment/README.md @@ -5,15 +5,14 @@ and running to which a Porch instance running in Visual Studio Code can connect # Setup kind with MetalLB and Gitea -Follow steps 1-5 inclusive of the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch) tutorial. You now have 2 Kind clusters -running with Gitea installed. Gitea has the repositories `management` and `edge1` defined. +Follow steps 1-5 inclusive of the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch) tutorial. You now have two Kind clusters `management` and `edge1` running with Gitea installed on the `management` cluster. Gitea has the repositories `management` and `edge1` defined. -> **_NOTE:_** The [setup script](bin/setup.sh) automates steps 1-5 of the Starting with Porch tutorial. You may need to adaot this script to your local environment. +> **_NOTE:_** This [setup script](bin/setup.sh) automates steps 1-5 of the Starting with Porch tutorial. You may need to adaot this script to your local environment. -> **_NOTE:_** The [cleardown script script](bin/cleardown.sh) clears everything down by deleting the `management` and `edge1` Kind clusters. USE WITH CARE. +> **_NOTE:_** This [cleardown script script](bin/cleardown.sh) clears everything down by deleting the `management` and `edge1` Kind clusters. USE WITH CARE. -You can reach the Gitea web interface on the address reported byt he following command: +You can reach the Gitea web interface on the address reported by the following command: ``` kubectl get svc -n gitea gitea NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE @@ -38,7 +37,7 @@ kubectl wait --namespace porch-system \ --timeout=300s ``` -The Porch function runner should now be executing +The Porch function runner should now be executing: ``` kubectl get pod -n porch-system --selector=app=function-runner @@ -67,12 +66,11 @@ function-runner LoadBalancer 10.197.168.148 172.18.255.201 9445:31794/TC # Install Porch resources for standalone execution -The Porch server requires that the following resources are defined int he K8S cluster where it is executed: +The Porch server requires that the following resources are defined in the K8S cluster where it is executed: - The `porch-system` namespace, an API Service called `apiservice.apiregistration.k8s.io/v1alpha1.porch.kpt.dev` and the `service.api` service to expose the API Service. These resources are defined in the the file `deployments/local/localconfig.yaml` - the `repositories.config.porch.kpt.dev` and `functions.config.porch.kpt.dev` CRDs. These CRDs are defined in the `api/porchconfig/v1alpha1/` directory. - the `packagerevs.config.porch.kpt.dev` CRD. This CRD is defined in the `internal/api/porchinternal/v1alpha1/` directory. -- ``` kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/deployments/local/localconfig.yaml @@ -124,7 +122,7 @@ You can now launch the Porch server locally in VSCode by selecting the "Launch S # Create Repositories using your local Porch server -Follow step 6 to connect Gitea to Porch in the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch#connect-the-gitea-repositories-to-porch) tutorial to create the Gitea and external repositories in Porch. +To connect Gitea to Porch follow [step 6 in the Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch#connect-the-gitea-repositories-to-porch) tutorial to create the Gitea and external repositories in Porch. You will notice logging messages in VSCode when you run the command `kubectl apply -f porch-repositories.yaml` command. From a6c3011f8c26e24b0457bf245b3727036d4d2979 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 28 Feb 2024 13:21:17 +0000 Subject: [PATCH 6/9] Updated based on review comments --- docs/tutorials/porch-development-environment/README.md | 9 ++++----- .../tutorials/porch-development-environment/bin/setup.sh | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/porch-development-environment/README.md b/docs/tutorials/porch-development-environment/README.md index 860f0e64..471870e6 100644 --- a/docs/tutorials/porch-development-environment/README.md +++ b/docs/tutorials/porch-development-environment/README.md @@ -95,6 +95,7 @@ Check out porch and start vscode in the root of your checked out Porch repo. Edit your local `.vscode.launch.json` file as follows: 1. Change the `--kubeconfig` value to point at your local Kind cluster configuration file 2. Change the `--function-runner` IP address to that of the function runner service running in the Kind `management` cluster +3. You can specify `KUBECONFIG` in the `env` section of the configuration instead of using the `--kubeconfig` flag. ``` { @@ -107,18 +108,16 @@ Edit your local `.vscode.launch.json` file as follows: "--secure-port=9443", "--v=7", "--standalone-debug-mode", - "--kubeconfig=/home/sean-citizen/.kube/kind-management-config", + "--kubeconfig=${userHome}/.kube/kind-management-config", "--cache-directory=${workspaceFolder}/.cache", "--function-runner=172.18.255.201:9445" ], - "env": { - "KUBECONFIG": "/Users/liam/.kube/kind-management-config" - }, "cwd": "${workspaceFolder}" }, ``` -You can now launch the Porch server locally in VSCode by selecting the "Launch Server" configuration on the VSCode "Run and Debug" window. +You can now launch the Porch server locally in VSCode by selecting the "Launch Server" configuration on the VSCode "Run and Debug" window. for +more information please refer to the [VSCode debugging documentation](https://code.visualstudio.com/docs/editor/debugging). # Create Repositories using your local Porch server diff --git a/docs/tutorials/porch-development-environment/bin/setup.sh b/docs/tutorials/porch-development-environment/bin/setup.sh index 371ce238..c0a248a3 100755 --- a/docs/tutorials/porch-development-environment/bin/setup.sh +++ b/docs/tutorials/porch-development-environment/bin/setup.sh @@ -88,3 +88,5 @@ popd || exit popd || exit rm -fr "$TMP_DIR" + +kubectl config use-context kind-management From 38f664a5994e7c47628f754d59286128b9990924 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 1 Mar 2024 09:44:28 +0000 Subject: [PATCH 7/9] Fix typos found by reviewers --- docs/tutorials/porch-development-environment/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/porch-development-environment/README.md b/docs/tutorials/porch-development-environment/README.md index 471870e6..82d27b17 100644 --- a/docs/tutorials/porch-development-environment/README.md +++ b/docs/tutorials/porch-development-environment/README.md @@ -7,7 +7,7 @@ and running to which a Porch instance running in Visual Studio Code can connect Follow steps 1-5 inclusive of the [Starting with Porch](https://github.com/nephio-project/porch/tree/main/docs/tutorials/starting-with-porch) tutorial. You now have two Kind clusters `management` and `edge1` running with Gitea installed on the `management` cluster. Gitea has the repositories `management` and `edge1` defined. -> **_NOTE:_** This [setup script](bin/setup.sh) automates steps 1-5 of the Starting with Porch tutorial. You may need to adaot this script to your local environment. +> **_NOTE:_** This [setup script](bin/setup.sh) automates steps 1-5 of the Starting with Porch tutorial. You may need to adapt this script to your local environment. > **_NOTE:_** This [cleardown script script](bin/cleardown.sh) clears everything down by deleting the `management` and `edge1` Kind clusters. USE WITH CARE. @@ -69,8 +69,8 @@ function-runner LoadBalancer 10.197.168.148 172.18.255.201 9445:31794/TC The Porch server requires that the following resources are defined in the K8S cluster where it is executed: - The `porch-system` namespace, an API Service called `apiservice.apiregistration.k8s.io/v1alpha1.porch.kpt.dev` and the `service.api` service to expose the API Service. These resources are defined in the the file `deployments/local/localconfig.yaml` -- the `repositories.config.porch.kpt.dev` and `functions.config.porch.kpt.dev` CRDs. These CRDs are defined in the `api/porchconfig/v1alpha1/` directory. -- the `packagerevs.config.porch.kpt.dev` CRD. This CRD is defined in the `internal/api/porchinternal/v1alpha1/` directory. +- The `repositories.config.porch.kpt.dev` and `functions.config.porch.kpt.dev` CRDs. These CRDs are defined in the `api/porchconfig/v1alpha1/` directory. +- The `packagerevs.config.porch.kpt.dev` CRD. This CRD is defined in the `internal/api/porchinternal/v1alpha1/` directory. ``` kubectl apply -f https://raw.githubusercontent.com/nephio-project/porch/main/deployments/local/localconfig.yaml @@ -93,8 +93,8 @@ repositories config.porch.kpt.dev/v1alpha1 Check out porch and start vscode in the root of your checked out Porch repo. Edit your local `.vscode.launch.json` file as follows: -1. Change the `--kubeconfig` value to point at your local Kind cluster configuration file -2. Change the `--function-runner` IP address to that of the function runner service running in the Kind `management` cluster +1. Change the `--kubeconfig` value to point at your local Kind cluster configuration file. +2. Change the `--function-runner` IP address to that of the function runner service running in the Kind `management` cluster. 3. You can specify `KUBECONFIG` in the `env` section of the configuration instead of using the `--kubeconfig` flag. ``` From 4e72c2dde58a57d1aabd66e4635917437101a828 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 1 Mar 2024 10:03:40 +0000 Subject: [PATCH 8/9] Added copyright notices to scripts --- .../porch-development-environment/bin/cleardown.sh | 14 ++++++++++++++ .../porch-development-environment/bin/setup.sh | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/tutorials/porch-development-environment/bin/cleardown.sh b/docs/tutorials/porch-development-environment/bin/cleardown.sh index 2606074d..14138915 100755 --- a/docs/tutorials/porch-development-environment/bin/cleardown.sh +++ b/docs/tutorials/porch-development-environment/bin/cleardown.sh @@ -1,5 +1,19 @@ #! /bin/bash +# Copyright 2024 The kpt and Nephio Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + kind delete cluster --name management kind delete cluster --name edge1 diff --git a/docs/tutorials/porch-development-environment/bin/setup.sh b/docs/tutorials/porch-development-environment/bin/setup.sh index c0a248a3..d9b2942b 100755 --- a/docs/tutorials/porch-development-environment/bin/setup.sh +++ b/docs/tutorials/porch-development-environment/bin/setup.sh @@ -1,5 +1,19 @@ #! /bin/bash +# Copyright 2024 The kpt and Nephio Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + os_type=$(uname) if [ "$os_type" = "Darwin" ] then From 9ef11da39d4e1044673497af2c564f6a01575400 Mon Sep 17 00:00:00 2001 From: Liam Fallon <35595825+liamfallon@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:17:00 +0000 Subject: [PATCH 9/9] Update docs/tutorials/starting-with-porch/README.md Co-authored-by: Kushal Harish Naidu <159911459+kushnaidu@users.noreply.github.com> --- docs/tutorials/starting-with-porch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/starting-with-porch/README.md b/docs/tutorials/starting-with-porch/README.md index b001efc7..66bb1b26 100644 --- a/docs/tutorials/starting-with-porch/README.md +++ b/docs/tutorials/starting-with-porch/README.md @@ -1,6 +1,6 @@ # Starting with Porch Tutorial -This tutorial is a guide to installing and using Porch. It is based on the [Porch demo produced by Tal Liron of Google](https://github.com/tliron/klab/tree/main/environments/porch-demo). Users should be very comfortable with using with `git`, `docker`, and `kubernetes`. +This tutorial is a guide to installing and using Porch. It is based on the [Porch demo produced by Tal Liron of Google](https://github.com/tliron/klab/tree/main/environments/porch-demo). Users should be very comfortable with using `git`, `docker`, and `kubernetes`. # Table of Contents 1. [Prerequisites](#Prerequisites)