### Set Up Development Environment with Script Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md This script is used to set up the necessary development environment for the Porch project. It automates the installation and configuration of required tools and dependencies. ```bash https://github.com/nephio-project/porch/blob/main/scripts/setup-dev-env.sh ``` -------------------------------- ### Example Git Sync Logs Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet displays example output from the git-sync logs within a ConfigSync reconciler pod. It shows detailed information about the git operations, such as cloning the repository, fetching changes, and syncing commits. ```log INFO: detected pid 1, running init handler I0105 17:50:11.472934 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="" "cmd"="git config --global gc.autoDetach false" I0105 17:50:11.493046 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="" "cmd"="git config --global gc.pruneExpire now" I0105 17:50:11.513487 15 main.go:473] "level"=0 "msg"="starting up" "pid"=15 "args"=("/git-sync","--root=/repo/source","--dest=rev","--max-sync-failures=30","--error-file=error.json","--v=5") I0105 17:50:11.514044 15 main.go:923] "level"=0 "msg"="cloning repo" "origin"="http://172.18.255.200:3000/nephio/edge1.git" "path"="/repo/source" I0105 17:50:11.514061 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="" "cmd"="git clone -v --no-checkout -b main --depth 1 http://172.18.255.200:3000/nephio/edge1.git /repo/source" I0105 17:50:11.706506 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git rev-parse HEAD" I0105 17:50:11.729292 15 main.go:737] "level"=0 "msg"="syncing git" "rev"="HEAD" "hash"="385295a2143f10a6cda0cf4609c45d7499185e01" I0105 17:50:11.729332 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git fetch -f --tags --depth 1 http://172.18.255.200:3000/nephio/edge1.git main" I0105 17:50:11.920110 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git cat-file -t 385295a2143f10a6cda0cf4609c45d7499185e01" I0105 17:50:11.945545 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git rev-parse 385295a2143f10a6cda0cf4609c45d7499185e01" I0105 17:50:11.967150 15 main.go:726] "level"=1 "msg"="removing worktree" "path"="/repo/source/385295a2143f10a6cda0cf4609c45d7499185e01" I0105 17:50:11.967359 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git worktree prune" I0105 17:50:11.987522 15 cmd.go:48] "level"=5 "msg"="running command" "cwd"="/repo/source" "cmd"="git worktree add --detach /repo/source/385295a2143f10a6cda0cf4609c45d7499185e01 385295a2143f10a6cda0cf4609c45d7499185e01 --no-checkout" ``` -------------------------------- ### Create Namespace for Porch Demo Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md Creates a Kubernetes namespace named 'porch-demo' to isolate the Porch demonstration environment and its related resources. ```bash kubectl create namespace porch-demo ``` -------------------------------- ### Install Porch using Kpt Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet shows how to install Porch using Kpt packages. It involves fetching the package, rendering it, initializing live apply, and applying the package to the cluster. ```bash cd kpt_packages kpt pkg get https://github.com/nephio-project/catalog/tree/main/nephio/core/porch kpt fn render porch kpt live init porch # You only need to do this command once kpt live apply porch ``` -------------------------------- ### Install Go Development Environment Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/12_contributing/relevant_old_docs/environment-setup-vm.md Downloads and installs Go version 1.22.5 for the amd64 architecture to the '/usr/local' directory. It then updates the user's profile to include the Go binary directory in the PATH. ```bash wget -O - https://go.dev/dl/go1.22.5.linux-amd64.tar.gz | sudo tar -C /usr/local -zxvf - echo '' >> ~/.profile echo '# set PATH for go' >> ~/.profile echo 'if [ -d "/usr/local/go" ]' >> ~/.profile echo 'then' >> ~/.profile echo ' PATH="/usr/local/go/bin:$PATH"' >> ~/.profile echo 'fi' >> ~/.profile ``` -------------------------------- ### Install and Configure ConfigSync using Kpt Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet demonstrates the command-line operations to install ConfigSync on a workload cluster. It involves fetching the ConfigSync package, rendering it, initializing the live Kpt package, and applying it to the cluster. Dependencies include kpt and kubectl. ```bash export KUBECONFIG=~/.kube/kind-edge1-config cd kpt_packages kpt pkg get https://github.com/nephio-project/catalog/tree/main/nephio/core/configsync kpt fn render configsync kpt live init configsync kpt live apply configsync ``` -------------------------------- ### Build and Deploy Porch in Kind Kubernetes Cluster Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md This command builds the Porch service and deploys it into a Kubernetes Kind cluster. Ensure Docker and a Kubernetes environment are set up prior to execution. ```bash make run-in-kind ``` -------------------------------- ### Install Nephio Sandbox Environment Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/12_contributing/relevant_old_docs/environment-setup-vm.md Installs the Nephio sandbox environment on the VM using a provided script. It configures the installation with specific debug, branch, and user settings. ```bash wget -O - https://raw.githubusercontent.com/nephio-project/test-infra/main/e2e/provision/init.sh | \ sudo NEPHIO_DEBUG=false \ NEPHIO_BRANCH=main \ NEPHIO_USER=ubuntu \ bash ``` -------------------------------- ### Apply Porch Repository Configuration Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md Applies a YAML configuration file to define Gitea repositories within Porch. This step is crucial for setting up the repository structure that Porch will manage. ```bash kubectl apply -f examples/tutorials/starting-with-porch/porch-repositories.yaml ``` -------------------------------- ### Initialize and Apply Porch Kpt Package Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porch.md These commands initialize the kpt live environment and then apply the Porch kpt package to your Kubernetes cluster. This is the core deployment step. Ensure 'kpt' is installed and configured correctly. ```bash kpt live init && kpt live apply ``` -------------------------------- ### PackageVariantSet Example with Repository Selector (YAML) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/5_architecture_and_components/relevant_old_docs/package-variant.md An example PackageVariantSet in YAML format demonstrating the use of a repository selector. This targets repositories based on labels and specifies package names to be instantiated within those matching repositories. It shows how to select repositories with specific labels and override default package names. ```yaml spec: upstream: repo: example-repo package: foo revision: v1 targets: - repositorySelector: matchLabels: env: prod org: hr - repositorySelector: matchLabels: region: uswest1 packageNames: - foo-a - foo-b - foo-c ``` -------------------------------- ### Rerun Porch Setup Script Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/12_contributing/relevant_old_docs/dev-process.md This command executes the Porch development environment setup script. It should be run after deleting the Kind cluster to reinitialize the development environment. ```bash ./scripts/setup-dev-env.sh ``` -------------------------------- ### Install Porchctl CLI to Local Directory (No Root) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porchctl.md Installs the Porchctl CLI to the user's local bin directory (`~/.local/bin/`) without requiring root permissions. This involves extracting the binary, making it executable, creating the directory if it doesn't exist, and moving the binary. The user must then ensure `~/.local/bin` is in their `$PATH`. ```bash tar -xzf porchctl_{{% params "latestTag" %}}_linux_amd64.tar.gz chmod +x ./porchctl mkdir -p ~/.local/bin mv ./porchctl ~/.local/bin/porchctl ``` -------------------------------- ### Install Porchctl CLI to System Directory Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porchctl.md Installs the Porchctl CLI by extracting the downloaded tarball and moving the executable to `/usr/local/bin/` using `sudo` for root permissions. This method requires root access on the host machine. ```bash tar -xzf porchctl_{{% params "latestTag" %}}_linux_amd64.tar.gz | sudo install -o root -g root -m 0755 porchctl /usr/local/bin/ ``` -------------------------------- ### Create and Navigate to Porch Directory Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porch.md This command creates a new directory named 'porch-' and navigates into it. Replace '' with the specific Porch version you are installing. This step is crucial for organizing deployment files. ```bash mkdir porch-{{% params "latestTag" %}} && cd porch-{{% params "latestTag" %}} ``` -------------------------------- ### PackageVariantSet Static Configuration Example (YAML) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/5_architecture_and_components/relevant_old_docs/package-variant.md An example of a PackageVariantSet defining a static configuration for provisioning namespaces. It specifies the upstream package and lists target repositories and package names, demonstrating how to set identical labels across generated PackageVariants. ```yaml apiVersion: config.porch.kpt.dev/v1alpha2 kind: PackageVariantSet metadata: namespace: default name: example spec: upstream: repo: platform-catalog package: base-ns revision: v1 targets: - repositories: - name: cluster-01 packageNames: - ns-1 - ns-2 - ns-3 template: labels: package-type: namespace org: hr ``` -------------------------------- ### Download Porch Kpt Package Blueprint Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porch.md This command downloads the Porch kpt package blueprint tarball from GitHub releases. Ensure you have 'curl' installed. The 'v{{% params "latestTag" %}}' part specifies the version of the blueprint to download. ```bash curl -LO "https://github.com/nephio-project/porch/releases/download/v{{% params "latestTag" %}}/porch_blueprint.tar.gz" ``` -------------------------------- ### PackageVariantSet Example with Object Selector (YAML) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/5_architecture_and_components/relevant_old_docs/package-variant.md An example PackageVariantSet in YAML format utilizing an object selector. This targets arbitrary Kubernetes resources within the Porch cluster based on their API version, kind, and labels. This allows for flexible targeting criteria beyond just repositories. ```yaml spec: upstream: repo: example-repo package: foo revision: v1 targets: - objectSelector: apiVersion: krm-platform.bigco.com/v1 kind: Team matchLabels: org: hr role: dev ``` -------------------------------- ### PackageVariantSet Example with Explicit Repositories (YAML) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/5_architecture_and_components/relevant_old_docs/package-variant.md An example PackageVariantSet in YAML format. It specifies an upstream repository and package, and defines targets using an explicit list of repositories and package names. This configuration generates PackageVariant resources for each specified repository and package name combination. ```yaml apiVersion: config.porch.kpt.dev/v1alpha2 kind: PackageVariantSet metadata: namespace: default name: example spec: upstream: repo: example-repo package: foo revision: v1 targets: - repositories: - name: cluster-01 - name: cluster-02 - name: cluster-03 packageNames: - foo-a - foo-b - foo-c - name: cluster-04 packageNames: - foo-a - foo-b ``` -------------------------------- ### Render, Init, and Apply Gitea Kpt Package Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This sequence of kpt commands first renders the Gitea package (applying any transformations), then initializes the live package (a one-time operation), and finally applies the Gitea manifests to the Kubernetes cluster. This deploys Gitea. ```bash kpt fn render gitea kpt live init gitea # You only need to do this command once kpt live apply gitea ``` -------------------------------- ### Configure VM for Development Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/12_contributing/relevant_old_docs/environment-setup-vm.md Sets up the VM's bash environment by sourcing kubectl, kpt, and porchctl completions, adding a history alias, and configuring kubectl alias. It also adds the 'ubuntu' user to the 'syslog' and 'docker' groups. ```bash echo '' >> ~/.bashrc echo 'source <(kubectl completion bash)' >> ~/.bashrc echo 'source <(kpt completion bash)' >> ~/.bashrc echo 'source <(porchctl completion bash)' >> ~/.bashrc echo '' >> ~/.bashrc echo 'alias h=history' >> ~/.bashrc echo 'alias k=kubectl' >> ~/.bashrc echo '' >> ~/.bashrc echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc sudo usermod -a -G syslog ubuntu sudo usermod -a -G docker ubuntu ``` -------------------------------- ### Filter PackageRevisions by Labels (kubectl) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/working_with_package_revisions/inspecting-packages.md Uses kubectl to filter PackageRevision resources based on Kubernetes labels. This example specifically retrieves all PackageRevisions marked as the 'latest' revision. ```bash kubectl get packagerevisions -n default --selector 'kpt.dev/latest-revision=true' ``` -------------------------------- ### Verify Porch Repository Status Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md Retrieves and displays the status of repositories within the 'porch-demo' namespace. This command helps verify that the repository configurations have been applied correctly. ```bash kubectl get repositories -n porch-demo ``` -------------------------------- ### Retrieve Performance Metrics Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md Fetches all captured performance metrics from the Porch test execution using curl. The metrics are exposed via an HTTP endpoint, typically on port 2113. ```bash curl -k http://localhost:2113/metrics ``` -------------------------------- ### Execute Porch Performance Tests Source: https://github.com/nephio-project/porch/blob/main/test/performance/README.md Runs the end-to-end performance tests for Porch using Go. This command can be customized with parameters to control the number of repositories and package revisions for testing. ```bash E2E=1 go test -v ./... -repos=4 -packages=4 -timeout 60m ``` -------------------------------- ### List Porch Repositories using porchctl Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/relevant_old_docs/preparing-the-environment.md This command lists all available repositories managed by Porch. It requires the `porchctl` tool to be installed and configured. The output displays repository names, types, content status, deployment status, readiness, and address. ```bash porchctl repo -n porch-demo get 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 ``` -------------------------------- ### Propose and Approve Packages for Deployment using Porchctl Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/relevant_old_docs/preparing-the-environment.md This command sequence demonstrates how to propose and then approve packages for deployment using the `porchctl` command-line tool. This is a critical step in the package lifecycle, signaling readiness for deployment. ```bash porchctl rpkg propose edge1-a31b56c7db509652f00724dd49746660757cd98a --namespace=porch-demo edge1-a31b56c7db509652f00724dd49746660757cd98a proposed porchctl rpkg approve edge1-a31b56c7db509652f00724dd49746660757cd98a --namespace=porch-demo edge1-a31b56c7db509652f00724dd49746660757cd98a approved porchctl rpkg propose edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 --namespace=porch-demo edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 proposed porchctl rpkg approve edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 --namespace=porch-demo edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 approved ``` -------------------------------- ### Combine Multiple Field Selectors for PackageRevisions Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/working_with_package_revisions/inspecting-packages.md Demonstrates how to apply multiple filters simultaneously to PackageRevisions in the 'default' namespace. This example combines filtering by repository and lifecycle using the --field-selector flag. ```bash kubectl get packagerevisions -n default \ --field-selector 'spec.repository==porch-test,spec.lifecycle==Published' ``` -------------------------------- ### Initialize New Package (CLI) Source: https://context7.com/nephio-project/porch/llms.txt Initializes a new package from scratch within a specified repository and workspace. ```APIDOC ## Initialize New Package ### Description Initializes a new package from scratch within a specified repository and workspace. ### Command `porchctl rpkg init` ### Parameters - **** (string, required) - The name of the new package. - `--namespace` (string, optional) - The namespace for the package. - `--repository` (string, required) - The Porch repository to initialize the package in. - `--revision` (string, optional) - The initial revision of the package. - `--workspace` (string, required) - The workspace to initialize the package in. - `--description` (string, optional) - A description for the package. - `--keywords` (string, optional) - Keywords associated with the package. ### Example ```bash # Initialize a new package from scratch porchctl rpkg init myapp \ --namespace=default \ --repository=blueprints \ --revision=v1 \ --workspace=initial \ --description="My application package" \ --keywords=app,kubernetes # Pull package resources locally for editing porchctl rpkg pull default/myapp-v1 ./local-myapp/ ``` ``` -------------------------------- ### Get Gitea Kpt Package Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet uses kpt (Kubernetes package management tool) to fetch the Gitea package from a specific GitHub repository and branch. This package contains the necessary Kubernetes manifests for deploying Gitea. ```bash export KUBECONFIG=~/.kube/kind-management-config cd kpt_packages kpt pkg get https://github.com/nephio-project/catalog/tree/main/distros/sandbox/gitea ``` -------------------------------- ### Specific Package Operation and Lifecycle Timings PromQL Source: https://github.com/nephio-project/porch/blob/main/test/performance/promql_queries.txt These examples demonstrate how to get the exact duration for creating a specific package revision, including repository context, and how to retrieve the full lifecycle timing for a package by summing durations across all its operations. ```promql porch_operation_duration_seconds_sum{ operation="Create PackageRevision", package="test-package-0", repository="porch-metrics-test-0" } ``` ```promql sum by (operation) ( porch_operation_duration_seconds_sum{ package="test-package-0", repository="porch-metrics-test-0" } ) ``` -------------------------------- ### Clone Repository and Navigate Directory Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet clones the Porch repository from GitHub and then changes the current directory to the specified tutorial path. It's a common first step in setting up a project. ```bash git clone https://github.com/nephio-project/porch.git cd porch/examples/tutorials/starting-with-porch/ ``` -------------------------------- ### Git Repository with Periodic Sync (YAML) Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/configurations/repository-sync.md An example of a Git repository configuration in Porch that includes a periodic synchronization schedule. The `schedule` field is set to "0 * * * *" to trigger a sync every hour. This setup ensures that the Porch cache stays updated with the latest changes in the specified Git repository branch. ```yaml apiVersion: config.porch.kpt.dev/v1alpha1 kind: Repository metadata: name: blueprints namespace: default spec: description: Blueprints with hourly sync type: git sync: schedule: "0 * * * *" # Every hour git: repo: https://github.com/example/blueprints.git branch: main directory: packages ``` -------------------------------- ### Install Delve Debugger Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/12_contributing/relevant_old_docs/environment-setup-vm.md Installs the Delve debugger, a debugger for the Go programming language, using 'go install'. This enables remote debugging capabilities for Go applications like Porch. ```bash go install -v github.com/go-delve/delve/cmd/dlv@latest ``` -------------------------------- ### Initialize Management Repository Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This sequence of bash commands initializes the 'management' repository. It involves cloning the repository, creating a README, making an initial commit, and pushing it to the remote origin. ```bash cd ../repos git clone http://172.18.255.200:3000/nephio/management cd management 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 cd .. ``` -------------------------------- ### Install MetalLB on Management Cluster Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This sequence installs MetalLB, a network load balancer, onto the management cluster using a raw YAML manifest. It then waits for the MetalLB controller pods to become ready, ensuring the load balancer is operational. ```bash export KUBECONFIG=~/.kube/kind-management-config 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 ``` -------------------------------- ### Create Gitea Repositories via cURL Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This snippet demonstrates how to create 'management' and 'edge1' repositories on a Gitea instance using cURL commands. It requires the Gitea API to be accessible and uses basic authentication. ```bash 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"}' ``` -------------------------------- ### Initialize and Apply Package with kpt Live CLI Source: https://github.com/nephio-project/porch/blob/main/pkg/task/testdata/init/testpkg/README.md Initializes a package for live apply and then applies it using kpt's live functionality. The apply command includes options for reconcile timeout and output format. Requires the package name. ```bash kpt live init testpkg kpt live apply testpkg --reconcile-timeout=2m --output=table ``` -------------------------------- ### Pull, Render, and Push Packages using Porchctl and Kpt Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/relevant_old_docs/preparing-the-environment.md This section details the process of pulling packages from a repository, applying a namespace using kpt functions, and then pushing the modified packages back. It's crucial for customizing deployed packages before they are finalized. ```bash porchctl rpkg pull edge1-a31b56c7db509652f00724dd49746660757cd98a tmp_packages_for_deployment/edge1-network-function-b --namespace=porch-demo kpt fn eval --image=gcr.io/kpt-fn/set-namespace:v0.4.1 tmp_packages_for_deployment/edge1-network-function-b -- namespace=network-function-b porchctl rpkg push edge1-a31b56c7db509652f00724dd49746660757cd98a tmp_packages_for_deployment/edge1-network-function-b --namespace=porch-demo porchctl rpkg pull edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 tmp_packages_for_deployment/edge1-network-function-c --namespace=porch-demo kpt fn eval --image=gcr.io/kpt-fn/set-namespace:v0.4.1 tmp_packages_for_deployment/edge1-network-function-c -- namespace=network-function-c porchctl rpkg push edge1-ee14f7ce850ddb0a380cf201d86f48419dc291f4 tmp_packages_for_deployment/edge1-network-function-c --namespace=porch-demo ``` -------------------------------- ### Configure RootSync for Repository Synchronization Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/install-porch.md This section outlines the steps to set up a RootSync Custom Resource (CR) to synchronize a specified Git repository. It involves fetching the RootSync package, editing its configuration files (package-context.yaml and rootsync.yaml) to point to the correct repository and authentication settings, rendering the package, and then initializing and applying the RootSync CR. ```bash kpt pkg get https://github.com/nephio-project/catalog/tree/main/nephio/optional/rootsync # Edit rootsync/package-context.yaml # Example changes: # < name: example-rootsync # > name: edge1 kpt fn render rootsync # Edit rootsync/rootsync.yaml # Example changes: # < repo: http://172.18.0.200:3000/nephio/example-cluster-name.git # > repo: http://172.18.255.200:3000/nephio/edge1.git # 13,15c13,16 # < auth: token # < secretRef: # < name: example-cluster-name-access-token-configsync # --- # > auth: none # > # auth: token # > # secretRef: # > # name: edge1-access-token-configsync export KUBECONFIG=~/.kube/kind-edge1-config kpt live init rootsync # This command is only needed once kpt live apply rootsync ``` -------------------------------- ### free5gc-cpAUSF ConfigMap Example Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/4_tutorials_and_how-tos/relevant_old_docs/preparing-the-environment.md An example Kubernetes ConfigMap for the AUSF (Authentication Server Function) within the free5gc package. It includes configuration data for the AUSF, specifying version and description. ```yaml ---\napiVersion: v1 kind: ConfigMap metadata: name: ausf-configmap labels: app.kubernetes.io/version: "v3.1.1" app: free5gc data: ausfcfg.yaml: | info: version: 1.0.2 description: ``` -------------------------------- ### Create and Publish PackageRevision (Go) Source: https://context7.com/nephio-project/porch/llms.txt Demonstrates the full lifecycle of creating and publishing a package revision. It first creates a draft package, updates its resources, proposes it for review, and finally publishes it. This function requires an initialized controller-runtime client and returns an error if any step fails. ```go package main import ( "context" "fmt" porchapi "github.com/nephio-project/porch/api/porch/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) func createAndPublishPackage(c client.Client) error { ctx := context.Background() // Step 1: Create draft package revision pkgRev := &porchapi.PackageRevision{ ObjectMeta: metav1.ObjectMeta{ Name: "myapp-v1-draft", Namespace: "default", }, Spec: porchapi.PackageRevisionSpec{ PackageName: "myapp", RepositoryName: "blueprints", WorkspaceName: "v1-draft", Revision: 1, Lifecycle: porchapi.PackageRevisionLifecycleDraft, Tasks: []porchapi.Task{ { Type: porchapi.TaskTypeInit, Init: &porchapi.PackageInitTaskSpec{ Description: "My application package", Keywords: []string{"app", "service"}, Site: "https://example.com", }, }, }, }, } if err := c.Create(ctx, pkgRev); err != nil { return fmt.Errorf("failed to create package revision: %w", err) } fmt.Printf("Created draft package: %s\n", pkgRev.Name) // Step 2: Update resources pkgRevResources := &porchapi.PackageRevisionResources{ ObjectMeta: metav1.ObjectMeta{ Name: pkgRev.Name, Namespace: pkgRev.Namespace, }, Spec: porchapi.PackageRevisionResourcesSpec{ PackageName: pkgRev.Spec.PackageName, WorkspaceName: pkgRev.Spec.WorkspaceName, Revision: pkgRev.Spec.Revision, RepositoryName: pkgRev.Spec.RepositoryName, Resources: map[string]string{ "deployment.yaml": `apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 2 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: myapp:latest`, }, }, } if err := c.Update(ctx, pkgRevResources); err != nil { return fmt.Errorf("failed to update resources: %w", err) } // Step 3: Propose package pkgRev.Spec.Lifecycle = porchapi.PackageRevisionLifecycleProposed if err := c.Update(ctx, pkgRev); err != nil { return fmt.Errorf("failed to propose package: %w", err) } fmt.Println("Package proposed for review") // Step 4: Approve and publish pkgRev.Spec.Lifecycle = porchapi.PackageRevisionLifecyclePublished if err := c.Update(ctx, pkgRev); err != nil { return fmt.Errorf("failed to publish package: %w", err) } fmt.Printf("Package published: %s\n", pkgRev.Name) return nil } ``` -------------------------------- ### Extract Porch Kpt Package Contents Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/3_getting_started/installing-porch.md This command extracts the contents of the downloaded 'porch_blueprint.tar.gz' file. Ensure you have 'tar' installed. This will unpack the necessary files for deploying Porch. ```bash tar -xzf porch_blueprint.tar.gz ``` -------------------------------- ### Get Repositories using kubectl Source: https://github.com/nephio-project/porch/blob/main/docs/content/en/docs/6_configuration_and_deployments/relevant_old_docs/environment-setup.md Retrieves a list of all repositories from the 'porch-demo' namespace using kubectl. This command provides an alternative way to verify repository status. ```bash kubectl get repositories -n porch-demo ```