Kubernetes Work API
Перейти к файлу
Ryan Zhang 40d16950ce
Merge pull request #119 from Azure/dependabot/go_modules/golang.org/x/text-0.3.8
chore: Bump golang.org/x/text from 0.3.7 to 0.3.8
2023-10-26 18:39:01 -07:00
.github Update pr-title-config.json 2023-10-26 17:59:36 -07:00
cmd/workcontroller add work agent join/leave 2022-09-13 22:44:41 -07:00
config use three way patch instead of server side apply 2022-08-25 01:05:57 -07:00
deploy Fix: Clientset Removal (#66) 2022-07-15 18:11:47 -07:00
deploy-work-api Allowing work namespace to be chosen by the users. (#92) 2022-07-28 13:27:18 -07:00
docs/proposals Add work api design doc 2021-02-22 15:42:12 +08:00
examples refactor code 2022-08-17 00:14:12 -07:00
hack Fix: Clientset Removal (#66) 2022-07-15 18:11:47 -07:00
makefiles CI: Added & updated GitHub workflows & templates & makefile. (#1) (#6) 2022-06-03 17:02:51 -07:00
pkg fix test 2022-09-13 23:13:01 -07:00
script fix the nil crash and ignore ordinal in compare resources 2022-09-06 15:30:35 -07:00
tests/e2e fix the nil crash and ignore ordinal in compare resources 2022-09-06 15:30:35 -07:00
tools CI: Added & updated GitHub workflows & templates & makefile. (#1) (#6) 2022-06-03 17:02:51 -07:00
version Refactor: adjust the reconciler (#17) 2022-06-14 14:32:04 -07:00
.gitignore applied work poc 2022-06-01 14:47:07 -07:00
CONTRIBUTING.md Update template files to include repo-specific info 2021-02-01 20:13:24 +05:30
Dockerfile adding version to dockerfile (#23) 2022-06-15 10:24:58 -07:00
LICENSE Initial commit 2021-02-01 20:09:41 +05:30
Makefile fix test 2022-08-19 19:39:57 -07:00
OWNERS Add qiujian16 as owner 2022-03-29 09:40:38 +08:00
README.md fix test 2022-08-19 19:39:57 -07:00
RELEASE.md Initial commit 2021-02-01 20:09:41 +05:30
SECURITY.md Initial commit 2021-02-01 20:09:41 +05:30
SECURITY_CONTACTS Update template files to include repo-specific info 2021-02-01 20:13:24 +05:30
code-of-conduct.md Initial commit 2021-02-01 20:09:41 +05:30
go.mod fix go sum 2023-10-26 18:36:08 -07:00
go.sum fix go sum 2023-10-26 18:36:08 -07:00

README.md

Work API

This repo will hold design documents and implementation of the Work API.

GitHub go.mod Go version Build Status codecov issues Activity

GitHub release (latest by date)

Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the community page.

You can reach the maintainers of this project at:

Quick Start

This guide will cover:

  • Create a kind cluster that acts as the hub work delivery control plane.
  • Create a kind cluster that acts as the spoke cluster for the work to be delivery to.
  • Install the work CRD to the hub cluster.
  • Install the appliedwork CRD to the spoke cluster.
  • Install the work agent components to the spoke cluster.
  • Deploy a work example on the hub cluster.
  • Verify all the contents inside the work has been delivered in the spoke cluster.

Prerequisites

Create and setup the Hub cluster

Open a new terminal window and run the following commands:

cd /tmp
git clone git@github.com:kubernetes-sigs/work-api.git
kind delete cluster --name hub 
kind create cluster --name hub
kind get kubeconfig --name hub  > /tmp/hub-io-kubeconfig
export KUBECONFIG=/tmp/hub-io-kubeconfig
cd /tmp/work-api
kubectl apply -f config/crd
cp /tmp/hub-io-kubeconfig hub-kubeconfig
kubectl config set clusters.kind-hub.server https://hub-control-plane:6443 --kubeconfig hub-kubeconfig

Create and setup the Spoke cluster

Open another new terminal window and run the following commands:

kind delete cluster --name cluster1
kind create cluster --name cluster1
kind get kubeconfig --name cluster1 > /tmp/cluster1-io-kubeconfig
export KUBECONFIG=/tmp/cluster1-io-kubeconfig
cd /tmp/work-api
make docker-build
kind load docker-image --name=cluster1 work-api-controller:latest
kubectl apply -f deploy/component_namespace.yaml 
kubectl delete secret hub-kubeconfig-secret -n fleet-system --ignore-not-found
kubectl create secret generic hub-kubeconfig-secret --from-file=kubeconfig=hub-kubeconfig -n fleet-system 
rm hub-kubeconfig
kubectl apply -k deploy

Run the controller against the Spoke cluster locally

Create a secret in the Spoke cluster that contains the kubconfig file pointing to the hub and run your code against.

kubectl create namespace fleet-system
kubectl delete secret hub-kubeconfig-secret -n fleet-system
kubectl create secret generic hub-kubeconfig-secret --from-file=kubeconfig=/Users/ryanzhang/.kube/hub -n fleet-system
go run cmd/workcontroller/workcontroller.go --work-namespace=default --hub-kubeconfig-secret=hub-kubeconfig-secret -v 5 -add_dir_header

Run the e2e against a cluster locally

Create a secret in the cluster that contains the kubconfig file pointing to itself. Run the feature code against it.

kubectl create namespace fleet-system
kubectl delete secret hub-kubeconfig-secret -n fleet-system
kubectl create secret generic hub-kubeconfig-secret --from-file=kubeconfig=/Users/ryanzhang/.kube/member-a -n fleet-system
go run cmd/workcontroller/workcontroller.go --work-namespace=default --hub-kubeconfig-secret=hub-kubeconfig-secret -v 5 -add_dir_header

run the test in another window

export KUBECONFIG=kubeconfig=/Users/ryanzhang/.kube/member-a
go test . -test.v -ginkgo.v

Deploy a Work on the Hub cluster

On the Hub cluster terminal, run the following command:

kubectl apply -f examples/example-work.yaml

Verify delivery on the Spoke cluster

On the Spoke cluster terminal, run the following commands:

$ kubectl -n default get deploy test-nginx
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
test-nginx   2/2     2            2           32s
$ kubectl -n default get service test-nginx
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
test-nginx   ClusterIP   10.96.96.136   <none>        80/TCP    46s

Modify the Work on the Hub cluster

On the Hub cluster terminal, run the following command:

kubectl apply -f examples/example-work-modify.yaml

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.