Skip to content

Commit dd80d86

Browse files
authored
operator: Publish docs as public website (grafana#6449)
1 parent 56bf3a4 commit dd80d86

Some content is hidden

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

48 files changed

+3065
-55
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "operator/website/themes/doks"]
2+
path = operator/website/themes/doks
3+
url = https://github.com/h-enk/doks.git

operator/.bingo/Variables.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ $(KIND): $(BINGO_DIR)/kind.mod
4747
@echo "(re)installing $(GOBIN)/kind-v0.11.0"
4848
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.11.0 "sigs.k8s.io/kind"
4949

50+
HUGO := $(GOBIN)/hugo-v0.80.0
51+
$(HUGO): $(BINGO_DIR)/hugo.mod
52+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
53+
@echo "(re)installing $(GOBIN)/hugo-v0.80.0"
54+
@cd $(BINGO_DIR) && CGO_ENABLED=1 $(GO) build -tags=extended -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.80.0 "github.com/gohugoio/hugo"
55+
5056
KUSTOMIZE := $(GOBIN)/kustomize-v4.2.0
5157
$(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
5258
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

operator/.bingo/hugo.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.17
4+
5+
replace github.com/markbates/inflect => github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6
6+
7+
require github.com/gohugoio/hugo v0.80.0 // CGO_ENABLED=1 -tags=extended

operator/.bingo/hugo.sum

Lines changed: 1250 additions & 0 deletions
Large diffs are not rendered by default.

operator/.bingo/variables.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.38.0"
1818

1919
KIND="${GOBIN}/kind-v0.11.0"
2020

21+
HUGO="${GOBIN}/hugo-v0.80.0"
22+
2123
KUSTOMIZE="${GOBIN}/kustomize-v4.2.0"
2224

2325
LOGCLI="${GOBIN}/logcli-v1.6.2-0.20220407212443-2d9d0ee236ea"

operator/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ testbin/*
2323
*.swp
2424
*.swo
2525
*~
26+
27+
# website
28+
29+
website/public/*
30+
website/resources/*

operator/ADOPTERS.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
* [Red Hat](https://www.redhat.com)
1+
---
2+
title: Adopters
3+
lead: ""
4+
date: 2021-04-30T10:40:00+00:00
5+
lastmod: 2021-04-30T10:40:00+00:00
6+
draft: false
7+
images: []
8+
---
9+
10+
<!--
11+
12+
Insert your entry using this template keeping the list alphabetically sorted:
13+
14+
## <Company/Organization Name>
15+
16+
https://our-link.com/
17+
18+
Environments: AWS, Azure, Google Cloud, Bare Metal, etc
19+
20+
21+
Details (optional):
22+
- Ruler for LokiStack
23+
-->
24+
25+
This document tracks people and use cases for the Prometheus Operator in production. By creating a list of production use cases we hope to build a community of advisors that we can reach out to with experience using various the Prometheus Operator applications, operation environments, and cluster sizes. The Prometheus Operator development team may reach out periodically to check-in on how the Prometheus Operator is working in the field and update this list.
26+
27+
Go ahead and [add your organization](https://github.com/grafana/loki/edit/main/operator/ADOPTERS.md) to the list.
28+
29+
## Red Hat Inc
30+
31+
https://www.redhat.com
32+
33+
Environments: AWS, Azure, Google Cloud, Bare Metal, etc

operator/CONTRIBUTING.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,49 @@
1-
Contributing to Loki Operator
1+
---
2+
title: Contributing
3+
description: How can I contribute to the Loki Operator?
4+
lead: ""
5+
lastmod: "2021-03-08T08:48:57+00:00"
6+
draft: false
7+
images: []
8+
menu:
9+
docs:
10+
parent: prologue
11+
weight: 200
12+
toc: true
13+
---
214

3-
## Ideology
15+
This project is licensed under the [AGPLv3 license](../../../../../LICENSE) and accept
16+
contributions via GitHub pull requests. This document outlines some of the
17+
conventions on development workflow, contact points
18+
and other resources to make it easier to get your contribution accepted.
419

5-
OpenShift has proven to be a powerful and successful platform for running containers in production. Our primary goal is to bring Loki Operator to our customers. That being said, it is a very large platform intended for large-scale production use. It is not intended to be ephemeral.
20+
To maintain a safe and welcoming community, all participants must adhere to the
21+
project's [Code of Conduct](../../../../../CODE_OF_CONDUCT.md).
622

7-
The tools required to run and test an OCP cluster are complex and cumbersome. The current processes to build an OCP cluster include the slack cluster-bot, openshift-install script, and CRC. The fastest route to create a working OCP cluster is 45 minutes. CRC *may* be faster, but it requires over [half of your local machine's resources](https://coreos.slack.com/archives/GGUR75P60/p1591803889037800) and doesn’t handle sleeping/suspending very well. Using openshift-install comes with its own [headaches](https://coreos.slack.com/archives/GGUR75P60/p1615458361119300). These blockers cause a significant amount of [wasted time](https://coreos.slack.com/archives/GGUR75P60/p1599242159479000?thread_ts=1599241354.478700&cid=GGUR75P60) that could be spent on more valuable things.
23+
# Contributor License Agreement
824

9-
Nevertheless, I argue that none of this is necessary. The problems are caused when we bastardize a large, complex, production platform for testing and tooling. OpenShift is a superset of Kubernetes. Operators are now Kubernetes native. Given this reality, we have called the Loki Operator a Kubernetes operator rather than an OpenShift operator. This may seem like a trivial delineation, but it isn’t. The operator has been designed from the beginning using Kubernetes tools and APIs. This has allowed us to build, test, and deploy in very little time with very little effort. It is not uncommon to create a pull request and have it [reviewed and merged](https://github.com/grafana/loki/pulls?q=is%3Apr+is%3Aclosed) within 15 minutes.
25+
By contributing to this project you agree to the Contributor License Agreement.
1026

11-
There are certainly OCP exclusives that we want to program into the Loki Operator, but this shouldn’t block or break the primary objectives. In other words, the Loki Operator should be Kubernetes first and OpenShift second. The Loki Operator should be open to using the OpenShift APIs without requiring them. All tools, automation, scripts, make targets, etc, should work naturally with Kubernetes and Kubernetes compatible APIs. <u>OCP exclusives should be opt-in</u>. It might be natural for you to think this causes obstruction for deploying to OCP, but that is far from true. Packaging for OCP should be a scripted process that, once opted in, should build all of the necessary components. So far, it has proven to be successful.
27+
# Email and Chat
1228

13-
## Tooling
29+
The project currently uses the [Grafana Slack](https://grafana.slack.com):
30+
- [#loki-operator-dev](https://grafana.slack.com/archives/C02RFD9CWVA)
1431

15-
We use [KinD](https://github.com/kubernetes-sigs/kind) to deploy and test the Loki Operator. We have had no compatibility issues, no wasted time on a learning curve, no failed clusters, no token expirations, no cluster expirations, no spinning laptop fans from gluttonous virtual machines, etc. It takes approximately 20 seconds to create a local KinD cluster and your machine won’t even notice it’s running. The cluster is fully compatible with all Kubernetes APIs and the operator runs on KinD perfectly. After your KinD cluster is created your kubeconfig is updated and the Makefile will work. The Makefiles and scripts are written to work with kubectl. This abstraction prevents any unnecessary complications caused by magic processes like deploying images to internal clusters, etc.
32+
## Getting Started
1633

34+
- Fork the repository on GitHub
35+
- Read the [README](README.md) for build and test instructions
36+
- Play with the project, submit bugs, submit patches!
1737

18-
## Testing
38+
## Contribution Flow
1939

20-
Tests should be succinct and without dependencies. This means that unit tests are the de-facto form of testing the Loki Operator. Unit tests are written with the standard Go library using [testify](https://github.com/stretchr/testify) for assertions. [Counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) is included for generating test fakes and stubs for all dependencies. This library provides an API for generating fake implementations of interfaces for injecting them into testable units of code. Unit tests should implement or stub *only the parts required to test*. Large, all-inclusive structs should be avoided in favor of concise, single responsibility functions. This encourages small tests with minimal assertions to keep them hyper-focused, making tests easy to create *and* maintain.
40+
This is a rough outline of what a contributor's workflow looks like:
41+
42+
- Create a topic branch from where you want to base your work (usually `main`).
43+
- Make commits of logical units.
44+
- Make sure your commit messages are in the proper format (see below).
45+
- Push your changes to a topic branch in your fork of the repository.
46+
- Make sure the tests pass, and add any new tests as appropriate.
47+
- Submit a pull request to the original repository.
48+
49+
Thanks for your contributions!

operator/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# referenced here as make variables. For example: $(GOLANGCI_LINT)
33
include .bingo/Variables.mk
44

5+
WEBSITE_DIR ?= website
6+
WEBSITE_BASE_URL ?= https://loki-operator.dev
7+
58
# set the default target here, because the include above will automatically set
69
# it to the first defined target
710
.DEFAULT_GOAL := default
@@ -257,3 +260,29 @@ oci-build-calculator: ## Build the calculator image
257260
.PHONY: oci-push-calculator
258261
oci-push-calculator: ## Push the calculator image
259262
$(OCI_RUNTIME) push $(CALCULATOR_IMG)
263+
264+
##@ Website
265+
TYPES_V1BETA1_TARGET := $(shell find apis/loki -type f -iname "*_types.go")
266+
docs/operator/api.md: $(TYPES_V1BETA1_TARGET)
267+
po-docgen api $(TYPES_V1BETA1_TARGET) > $@
268+
sed -i 's/Prometheus Operator/Loki Operator/ig' $@
269+
270+
FEATURE_FLAGS_TARGET := $(shell find apis/config -type f -iname "*_types.go")
271+
docs/operator/feature-flags.md: $(FEATURE_FLAGS_TARGET)
272+
po-docgen api $(FEATURE_FLAGS_TARGET) > $@
273+
sed -i 's/title: "API"/title: "Feature Flags"/' $@
274+
sed -i 's/Prometheus Operator/Loki Operator/ig' $@
275+
276+
.PHONY: web-pre
277+
web-pre: docs/operator/api.md docs/operator/feature-flags.md
278+
@echo ">> preprocessing docs for website"
279+
@git submodule update --init --recursive
280+
cd $(WEBSITE_DIR)/themes/doks/ && npm install && rm -rf content
281+
282+
.PHONY: web
283+
web: $(HUGO) | web-pre ## Run production build of the loki-operator.dev website
284+
cd $(WEBSITE_DIR) && $(HUGO) -b $(WEBSITE_BASE_URL)
285+
286+
.PHONY: web-serve
287+
web-serve: $(HUGO) | web-pre ## Run local preview version of the loki-operator.dev website
288+
@cd $(WEBSITE_DIR) && $(HUGO) serve

operator/docs/_index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title : "Loki-Operator Docs"
3+
description: "Documentation for the Loki-Operator."
4+
lead: ""
5+
date: 2021-04-30T10:40:00+00:00
6+
lastmod: 2021-04-30T10:40:00+00:00
7+
draft: false
8+
images: []
9+
---
10+
11+
# Loki-Operator
12+
13+
A Kubernetes Operator for Loki provided by the Grafana Loki SIG operator.

0 commit comments

Comments
 (0)