Skip to content

docs: initial COSI docs website #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
enable-beta-ecosystems: true
updates:

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
groups: # batch updates together for fewer dependabot PRs
golang-dependencies:
patterns:
- "github.com/golang*"
- "golang.org/x*"
k8s-dependencies:
patterns:
- "k8s.io*"
- "sigs.k8s.io*"
exclude-patterns:
# controller-runtime has history of breaking API changes more often than other k8s projects
- "sigs.k8s.io/controller-runtime"
github-dependencies:
patterns:
- "github.com*"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
66 changes: 66 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Sample workflow for building and deploying a mdBook site to GitHub Pages
#
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
#
name: Deploy mdBook site to Pages

on:
# Runs on only core version tags
push:
tags:
- 'v*'
- '!v*-alpha*'
- '!v*-beta*'
- '!v*-pre*'
- '!v*-rc*'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
make mdbook
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./client/go.mod
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with mdBook
run: |
make build-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/book

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
77 changes: 53 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,22 @@ PLATFORM ?= linux/$(GOARCH)
BUILD_ARGS ?=

# Image tag for controller image build
CONTROLLER_TAG ?= cosi-controller:latest
CONTROLLER_TAG ?= localhost:5005/cosi-controller:dev-$(shell git describe --match='' --always --abbrev=6 --dirty)

# Image tag for sidecar image build
SIDECAR_TAG ?= cosi-provisioner-sidecar:latest
SIDECAR_TAG ?= localhost:5005/cosi-provisioner-sidecar:dev-$(shell git describe --match='' --always --abbrev=6 --dirty)

##@ Development

.PHONY: generate
generate: controller/Dockerfile sidecar/Dockerfile ## Generate files
generate: crd-ref-docs controller/Dockerfile sidecar/Dockerfile ## Generate files
$(MAKE) -C client crds
$(MAKE) -C proto generate
$(CRD_REF_DOCS) \
--config=./docs/.crd-ref-docs.yaml \
--source-path=./client/apis \
--renderer=markdown \
--output-path=./docs/src/api/
%/Dockerfile: hack/Dockerfile.in hack/gen-dockerfile.sh
hack/gen-dockerfile.sh $* > "$@"

Expand Down Expand Up @@ -107,6 +112,16 @@ build.controller: controller/Dockerfile ## Build only the controller container i
build.sidecar: sidecar/Dockerfile ## Build only the sidecar container image
$(DOCKER) build --file sidecar/Dockerfile --platform $(PLATFORM) $(BUILD_ARGS) --tag $(SIDECAR_TAG) .

.PHONY: build-docs
build-docs: generate mdbook
cd docs; $(MDBOOK) build

MDBOOK_PORT ?= 3000

.PHONY: serve-docs
serve-docs: generate mdbook
cd docs; $(MDBOOK) serve --port $(MDBOOK_PORT)

.PHONY: clean
clean: ## Clean build environment
$(MAKE) -C proto clean
Expand All @@ -121,11 +136,11 @@ clobber: ## Clean build environment and cached tools

.PHONY: cluster
cluster: kind ctlptl ## Create Kind cluster and local registry
$(CTLPTL) apply -f ctlptl.yaml
@PATH=$(TOOLBIN):$(PATH) $(CTLPTL) apply -f ctlptl.yaml

.PHONY: cluster-reset
cluster-reset: kind ctlptl ## Delete Kind cluster
$(CTLPTL) delete -f ctlptl.yaml
@PATH=$(TOOLBIN):$(PATH) $(CTLPTL) delete -f ctlptl.yaml

.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config
Expand All @@ -145,44 +160,58 @@ $(TOOLBIN):
mkdir -p $(TOOLBIN)

# Tool Binaries
CHAINSAW ?= $(TOOLBIN)/chainsaw
CTLPTL ?= $(TOOLBIN)/ctlptl
CHAINSAW ?= $(TOOLBIN)/chainsaw
CRD_REF_DOCS ?= $(TOOLBIN)/crd-ref-docs
CTLPTL ?= $(TOOLBIN)/ctlptl
GOLANGCI_LINT ?= $(TOOLBIN)/golangci-lint
KIND ?= $(TOOLBIN)/kind
KUSTOMIZE ?= $(TOOLBIN)/kustomize
KIND ?= $(TOOLBIN)/kind
KUSTOMIZE ?= $(TOOLBIN)/kustomize
MDBOOK ?= $(TOOLBIN)/mdbook

# Tool Versions
CHAINSAW_VERSION ?= $(shell grep 'github.com/kyverno/chainsaw ' ./hack/tools/go.mod | cut -d ' ' -f 2)
CTLPTL_VERSION ?= $(shell grep 'github.com/tilt-dev/ctlptl ' ./hack/tools/go.mod | cut -d ' ' -f 2)
GOLANGCI_LINT_VERSION ?= $(shell grep 'github.com/golangci/golangci-lint ' ./hack/tools/go.mod | cut -d ' ' -f 2)
KIND_VERSION ?= $(shell grep 'sigs.k8s.io/kind ' ./hack/tools/go.mod | cut -d ' ' -f 2)
KUSTOMIZE_VERSION ?= $(shell grep 'sigs.k8s.io/kustomize/kustomize/v5 ' ./hack/tools/go.mod | cut -d ' ' -f 2)
CHAINSAW_VERSION ?= v0.2.11
CRD_REF_DOCS_VERSION ?= v0.1.0
CTLPTL_VERSION ?= v0.8.35
GOLANGCI_LINT_VERSION ?= v1.61.0
KIND_VERSION ?= v0.24.0
KUSTOMIZE_VERSION ?= v5.5.0
MDBOOK_VERSION ?= v0.4.45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is dependabot managing these in the makefile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but while updating them, I had some conflict in the dependencies (which are shared in go.mod). It’s worth exploring how can we manage the dependencies without sharing their dependencies.


.PHONY: chainsaw
chainsaw: $(CHAINSAW)$(CHAINSAW_VERSION)
$(CHAINSAW)$(CHAINSAW_VERSION): $(TOOLBIN)
chainsaw: $(CHAINSAW)-$(CHAINSAW_VERSION)
$(CHAINSAW)-$(CHAINSAW_VERSION): $(TOOLBIN)
$(call go-install-tool,$(CHAINSAW),github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))

.PHONY: crd-ref-docs
crd-ref-docs: $(CRD_REF_DOCS)-$(CRD_REF_DOCS_VERSION)
$(CRD_REF_DOCS)-$(CRD_REF_DOCS_VERSION): $(TOOLBIN)
$(call go-install-tool,$(CRD_REF_DOCS),github.com/elastic/crd-ref-docs,$(CRD_REF_DOCS_VERSION))

.PHONY: ctlptl
ctlptl: $(CTLPTL)$(CTLPTL_VERSION)
$(CTLPTL)$(CTLPTL_VERSION): $(TOOLBIN)
ctlptl: $(CTLPTL)-$(CTLPTL_VERSION)
$(CTLPTL)-$(CTLPTL_VERSION): $(TOOLBIN)
$(call go-install-tool,$(CTLPTL),github.com/tilt-dev/ctlptl/cmd/ctlptl,$(CTLPTL_VERSION))

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT)$(GOLANGCI_LINT_VERSION)
$(GOLANGCI_LINT)$(GOLANGCI_LINT_VERSION): $(TOOLBIN)
golangci-lint: $(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION)
$(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION): $(TOOLBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: kind
kind: $(KIND)$(KIND_VERSION)
$(KIND)$(KIND_VERSION): $(TOOLBIN)
kind: $(KIND)-$(KIND_VERSION)
$(KIND)-$(KIND_VERSION): $(TOOLBIN)
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))

.PHONY: kustomize
kustomize: $(KUSTOMIZE)$(KUSTOMIZE_VERSION)
$(KUSTOMIZE)$(KUSTOMIZE_VERSION): $(TOOLBIN)
kustomize: $(KUSTOMIZE)-$(KUSTOMIZE_VERSION)
$(KUSTOMIZE)-$(KUSTOMIZE_VERSION): $(TOOLBIN)
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))

.PHONY: mdbook
mdbook: $(MDBOOK)-$(MDBOOK_VERSION)
$(MDBOOK)-$(MDBOOK_VERSION): $(TOOLBIN)
./hack/install-mdbook.sh $(MDBOOK) $(MDBOOK_VERSION)

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
8 changes: 8 additions & 0 deletions docs/.crd-ref-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
processor:
# RE2 regular expressions describing types that should be excluded from the generated documentation.
ignoreTypes: []
# RE2 regular expressions describing type fields that should be excluded from the generated documentation.
ignoreFields: []
render:
# Version of Kubernetes to use when generating links to Kubernetes API documentation.
kubernetesVersion: '1.32'
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
book
theme/index.hbs
13 changes: 13 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[book]
title = "Container Object Storage Interface"
description = "This site documents how to develop and deploy a Container Object Storage Interface (COSI) driver on Kubernetes."
authors = ["The Kubernetes Authors"]

[output.html]
git-repository-url = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs"
edit-url-template = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs/{path}"
additional-css = ["custom.css"]

[preprocessor.generate-version]
renderers = ["html"]
command = """sh -c 'scripts/generate-version.sh'"""
3 changes: 3 additions & 0 deletions docs/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#version {
font-size: .75em;
}
8 changes: 8 additions & 0 deletions docs/scripts/generate-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
jq ".[1]";
SHA=$(git rev-parse HEAD)
VERSION="Built from: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${SHA}\"><code>${SHA}<\/code><\/a>"
TAG=$(git tag --contains "$SHA" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$')
if [ -n "$TAG" ]; then
VERSION="Version: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${TAG}\"><code>${TAG}<\/code><\/a> ${VERSION}"
fi
sed "s/VERSION-PLACEHOLDER/${VERSION}/" theme/index-template.hbs > theme/index.hbs
16 changes: 16 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Summary

- [Introduction](./introduction.md)
- [Quick Start](./quick-start.md)
- [Tasks](./operations/tasks.md)
- [Installing COSI Driver](./operations/installing-driver.md)
- [Troubleshooting](./operations/troubleshooting.md)
- [Monitoring](./operations/monitoring.md)
- [Developer guide](./developing/guide.md)
- [Developing "core" COSI](./developing/core.md)
- [Developing a COSI Driver](./developing/drivers.md)
- [Developing client applications](./developing/clients.md)
- [Go](./developing/clients/go.md)
<!-- TODO(guides): add new guides -->
- [Drivers](./drivers.md)
- [API Reference](./api/out.md)
Loading