Skip to content

Commit 8ba9e0c

Browse files
authored
Merge pull request #91 from astoycos/add-more-docs-refactor-website
Add more docs, refactor website, add release tooling
2 parents 2cc1bfb + bf6f6c2 commit 8ba9e0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+752
-426
lines changed

Makefile

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ help: ## Display this help.
2626

2727
##@ Development
2828

29-
CLIENTSET_NAME ?= versioned
30-
CLIENTSET_PKG_NAME ?= clientset
31-
API_PKG ?= sigs.k8s.io/network-policy-api
32-
API_GROUP_NAME ?= policy.networking.k8s.io
33-
API_DIR ?= ${API_PKG}/apis/v1alpha1
34-
OUTPUT_PKG ?= sigs.k8s.io/network-policy-api/pkg/client
35-
COMMON_FLAGS ?= --go-header-file $(shell pwd)/hack/boilerplate.go.txt
36-
37-
.PHONY: manifests
38-
manifests: ## Generate ClusterRole and CustomResourceDefinition objects.
39-
go run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=manager-role crd paths=./apis/... output:crd:dir=./config/crd/bases output:stdout
40-
4129
.PHONY: fmt
4230
fmt: ## Run go fmt against code.
4331
go fmt ./...
@@ -47,50 +35,10 @@ vet: ## Run go vet against code.
4735
go vet ./...
4836

4937
.PHONY: generate
50-
generate: generate-deepcopy generate-typed-clients generate-typed-listers generate-typed-informers
51-
52-
.PHONY: generate-setup
53-
generate-setup:
54-
# Even when modules are enabled, the code-generator tools always write to
55-
# a traditional GOPATH directory, so fake on up to point to the current
56-
# workspace.
57-
mkdir -p "${GOPATH}/src/sigs.k8s.io"
58-
ln -sf "${ROOT_DIR}" "${GOPATH}/src/sigs.k8s.io/network-policy-api"
59-
60-
.PHONY: generate-cleanup
61-
generate-cleanup:
62-
rm -rf "${GOPATH}/src/sigs.k8s.io"
63-
64-
.PHONY: generate-deepcopy
65-
generate-deepcopy: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
66-
go run sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
38+
generate:
39+
./hack/update-codegen.sh
6740

68-
.PHONY: generate-typed-clients
69-
generate-typed-clients: ## Generate typed client code
70-
go run k8s.io/code-generator/cmd/client-gen \
71-
--clientset-name "${CLIENTSET_NAME}" \
72-
--input-base "" \
73-
--input "${API_DIR}" \
74-
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" \
75-
${COMMON_FLAGS}
76-
77-
.PHONY: generate-typed-listers
78-
generate-typed-listers: ## Generate typed listers code
79-
go run k8s.io/code-generator/cmd/lister-gen \
80-
--input-dirs "${API_DIR}" \
81-
--output-package "${OUTPUT_PKG}/listers" \
82-
${COMMON_FLAGS}
83-
84-
.PHONY: generate-typed-informers
85-
generate-typed-informers: ## Generate typed informers code
86-
go run k8s.io/code-generator/cmd/informer-gen \
87-
--input-dirs "${API_DIR}" \
88-
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}/${CLIENTSET_NAME}" \
89-
--listers-package "${OUTPUT_PKG}/listers" \
90-
--output-package "${OUTPUT_PKG}/informers" \
91-
${COMMON_FLAGS}
92-
93-
all: generate manifests fmt vet ## Runs all the development targets
41+
all: generate fmt vet ## Runs all the development targets
9442

9543
.PHONY: verify
9644
verify:
@@ -100,10 +48,10 @@ crd-e2e:
10048
hack/crd-e2e.sh -v
10149

10250
##@ Deployment
103-
install: manifests ## Install CRDs into the K8s cluster specified in ~/.kube/config.
51+
install: generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
10452
kubectl kustomize config/crd | kubectl apply -f -
10553

106-
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
54+
uninstall: generate kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
10755
kubectl kustomize config/crd | kubectl delete -f -
10856

10957
.PHONY: docs ## Build the documentation website
@@ -112,4 +60,8 @@ docs:
11260

11361
.PHONY: local-docs ## Deploy the docs locally
11462
local-docs:
115-
mkdocs serve
63+
mkdocs serve
64+
65+
.PHONY: build-install-yaml
66+
build-install-yaml:
67+
./hack/build-install-yaml.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<img src="https://github.com/kubernetes/kubernetes/raw/master/logo/logo.png" width="100">
22

33
# Network Policy API
4-
👋 Welcome to the Network Policy API Project - we are happy to have you here! Before you get started here are some useful links:
4+
Welcome to the Network Policy API Project - we are happy to have you here! Before you get started here are some useful links:
55
- [Our Website](https://network-policy-api.sigs.k8s.io/)
66
- [Agenda](https://docs.google.com/document/d/1AtWQy2fNa4qXRag9cCp5_HsefD7bxKe3ea2RPn8jnSs/edit#heading=h.ajvcztp6cza)
77
- [NetworkPolicy v1 Docs](https://kubernetes.io/docs/concepts/services-networking/network-policies/)

RELEASE.md

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,97 @@
11
# Release Process
22

3-
The Kubernetes Template Project is released on an as-needed basis. The process is as follows:
3+
## Overview
44

5-
1. An issue is proposing a new release with a changelog since the last release
6-
1. All [OWNERS](OWNERS) must LGTM this release
7-
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
8-
1. The release issue is closed
9-
1. An announcement email is sent to `[email protected]` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released`
5+
The Network Policy API project is has the following two main release components:
6+
- Kubernetes Custom Resource Definitions (CRDs)
7+
- Corresponding Go bindings for the API (`sigs.k8s.io/network-policy-api` Go package)
8+
9+
This repository is the home for both of the above components.
10+
11+
## Versioning strategy
12+
The versioning strategy for this project is covered in detail in [the release
13+
documentation].
14+
15+
[the release documentation]: site-src/versioning.md
16+
17+
Adapted with :blue_heart: from the [gateway api project release documentation](https://gateway-api.sigs.k8s.io/)
18+
19+
## Releasing a new version
20+
21+
### Writing a Changelog
22+
23+
To simplify release notes generation, we recommend using the [Kubernetes release
24+
notes generator](https://github.com/kubernetes/release/blob/master/cmd/release-notes):
25+
26+
```
27+
go install k8s.io/release/cmd/release-notes@latest
28+
export GITHUB_TOKEN=your_token_here
29+
release-notes --start-sha EXAMPLE_COMMIT --end-sha EXAMPLE_COMMIT --branch main --repo network-policy-api --org kubernetes-sigs
30+
```
31+
32+
This output will likely need to be reorganized and cleaned up a bit, but it
33+
provides a good starting point. Once you're satisfied with the changelog, create
34+
a PR. This must go through the regular PR review process and get merged into the
35+
`main` branch. Approval of the PR indicates community consensus for a new
36+
release.
37+
38+
### Release Steps
39+
40+
The following steps must be done by one of the [network-policy API maintainers][network-policy-api-team]:
41+
42+
For a **PATCH** release:
43+
- Create a new branch in your fork named something like `<githubuser>/release-x.x.x`. Use the new branch
44+
in the upcoming steps.
45+
- Use `git` to cherry-pick all relevant PRs into your branch.
46+
- Update `pkg/generator/main.go` with the new semver tag and any updates to the API review URL.
47+
- Run the following command `BASE_REF=vmajor.minor.patch make generate` which
48+
will update generated docs and webhook with the correct version info. (Note
49+
that you can't test with these YAMLs yet as they contain references to
50+
elements which wont exist until the tag is cut and image is promoted to
51+
production registry.)
52+
- Create a pull request of the `<githubuser>/release-x.x.x` branch into the `release-x.x` branch upstream
53+
(which should already exist since this is a patch release). Add a hold on this PR waiting for at least
54+
one maintainer/codeowner to provide a `lgtm`.
55+
- Verify the CI tests pass and merge the PR into `release-x.x`.
56+
- Create a tag using the `HEAD` of the `release-x.x` branch. This can be done using the `git` CLI or
57+
Github's [release][release] page.
58+
- Run the `make build-install-yaml` command which will generate install files in the `release/` directory.
59+
Attach these files to the Github release.
60+
- Update the `README.md` and `site-src/guides/index.md` files to point links and examples to the new release.
61+
62+
For a **MAJOR** or **MINOR** release:
63+
64+
- Cut a `release-major.minor` branch that we can tag things in as needed.
65+
- Check out the `release-major.minor` release branch locally.
66+
- Update `pkg/generator/main.go` with the new semver tag and any updates to the API review URL.
67+
- Run the following command `BASE_REF=vmajor.minor.patch make generate` which
68+
will update generated docs and webhook with the correct version info. (Note
69+
that you can't test with these YAMLs yet as they contain references to
70+
elements which wont exist until the tag is cut and image is promoted to
71+
production registry.)
72+
- Verify the CI tests pass before continuing.
73+
- Create a tag using the `HEAD` of the `release-x.x` branch. This can be done using the `git` CLI or
74+
Github's [release][release] page.
75+
- Run the `make build-install-yaml` command which will generate install files in the `release/` directory.
76+
Attach these files to the Github release.
77+
- Update the `README.md` and `site-src/guides/index.md` files to point links and examples to the new release.
78+
79+
For an **RC** release:
80+
81+
- Update `pkg/generator/main.go` with the new semver tag and any updates to the API review URL.
82+
- Run the following command `BASE_REF=vmajor.minor.patch make generate` which
83+
will update generated docs and webhook with the correct version info. (Note
84+
that you can't test with these YAMLs yet as they contain references to
85+
elements which wont exist until the tag is cut and image is promoted to
86+
production registry.)
87+
- Include the changelog update in this PR.
88+
- Merge the update PR.
89+
- Tag the release using the commit on `main` where the changelog update merged.
90+
This can be done using the `git` CLI or Github's [release][release]
91+
page.
92+
- Run the `make build-install-yaml` command which will generate
93+
install files in the `release/` directory.
94+
- Attach these files to the Github release.
95+
96+
[release]: https://github.com/kubernetes-sigs/network-policy-api/releases
97+
[network-policy-api-team]: https://github.com/kubernetes/org/blob/main/config/kubernetes-sigs/sig-network/teams.yaml

apis/v1alpha1/adminnetworkpolicy_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
// +kubebuilder:printcolumn:name="Priority",type=string,JSONPath=".spec.priority"
3232
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
3333
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
34-
// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes/enhancements/pull/2522"
3534
// AdminNetworkPolicy is a cluster level resource that is part of the
3635
// AdminNetworkPolicy API.
3736
type AdminNetworkPolicy struct {

apis/v1alpha1/baselineadminnetworkpolicy_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
// +kubebuilder:resource:shortName=banp,scope=Cluster
2727
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
2828
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
29-
// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes/enhancements/pull/2522"
3029
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default'",message="Only one baseline admin network policy with metadata.name=\"default\" can be created in the cluster"
3130
// BaselineAdminNetworkPolicy is a cluster level resource that is part of the
3231
// AdminNetworkPolicy API.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/register.go renamed to apis/v1alpha1/zz_generated.register.go

Lines changed: 29 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/kustomization.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5-
- bases/policy.networking.k8s.io_adminnetworkpolicies.yaml
6-
- bases/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml
5+
- policy.networking.k8s.io_adminnetworkpolicies.yaml
6+
- policy.networking.k8s.io_baselineadminnetworkpolicies.yaml
77
#+kubebuilder:scaffold:crdkustomizeresource
88

9-
# patchesStrategicMerge:
10-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
11-
# patches here are for enabling the conversion webhook for each CRD
12-
#- patches/webhook_in_adminnetworkpolicies.yaml
13-
#+kubebuilder:scaffold:crdkustomizewebhookpatch
14-
159
# the following config is for teaching kustomize how to do kustomization for CRDs.
1610
configurations:
1711
- kustomizeconfig.yaml

config/crd/patches/webhook_in_adminnetworkpolicies.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

config/crd/patches/webhook_in_baselineadminnetworkpolicies.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)