diff --git a/.github/workflows/update-readme.yaml b/.github/workflows/update-readme.yaml index 21023158..21490155 100644 --- a/.github/workflows/update-readme.yaml +++ b/.github/workflows/update-readme.yaml @@ -29,7 +29,7 @@ jobs: - name: set up uses: actions/setup-go@v4 with: - go-version: ^1.18 + go-version-file: go.mod - name: update readme run: go run readme.go diff --git a/README.md b/README.md index b41bcc9a..15823dfc 100755 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ - Kind: [v0.17.0](https://github.com/kubernetes-sigs/kind/releases/tag/v0.17.0) - Ingress Nginx Controller: [controller-v1.7.0](https://github.com/kubernetes/ingress-nginx/releases/tag/controller-v1.7.0) - Conftest: [v0.25.0](https://github.com/open-policy-agent/conftest/releases/tag/v0.25.0) -- Istio: [1.18.2](https://github.com/istio/istio/releases/tag/1.18.2) +- Istio: [1.19.0](https://github.com/istio/istio/releases/tag/1.19.0) - Postgres Operator: [v1.7.1](https://github.com/zalando/postgres-operator/releases/tag/v1.7.1) - KNative: [](https://github.com/knative/serving) - Skaffold: [v1.39.1](https://github.com/GoogleContainerTools/skaffold/releases/tag/v1.39.1) diff --git a/contents/README.md b/contents/README.md index f2e7e14b..88667cae 100644 --- a/contents/README.md +++ b/contents/README.md @@ -2,19 +2,19 @@ # Versions -1. Kubernetes: [v1.21.2](https://github.com/kubernetes/kubernetes/releases/tag/v1.21.2) (released on 2021-06-18) +1. Kubernetes: [v1.25.3](https://github.com/kubernetes/kubernetes/releases/tag/v1.25.3) 1. kustomize: [v4.2.0](https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv4.2.0) (released on 2021-07-02) -1. Helm: [3.6.3](https://github.com/helm/helm/releases/tag/v3.6.3) (released on 2021-07-15) +1. Helm: [v3.11.2](https://github.com/helm/helm/releases/tag/v3.11.2) 1. Traefik: [v2.9.0](https://github.com/traefik/traefik/releases/tag/v2.9.0) -1. ArgoCD: [v2.2.3](https://github.com/argoproj/argo-cd/releases/tag/v2.2.3) (released on 2022-01-19) -1. Prometheus-Operator: [v0.53.1](https://github.com/prometheus-operator/prometheus-operator/releases/tag/v0.53.1) (released on 2021-12-20) -1. Prometheus: Latest -1. Grafana: Latest -1. Strimzi: [0.24.0](https://github.com/strimzi/strimzi-kafka-operator/releases/tag/0.24.0) (released on 2021-06-24) -1. Kind: [v0.11.1](https://github.com/kubernetes-sigs/kind/releases/tag/v0.11.1) (released on 2021-05-28) -1. Ingress Nginx Controller: [v0.48.0](https://github.com/kubernetes/ingress-nginx/releases/tag/controller-v0.48.1) (released on 2021-07-15) -1. Conftest: [0.25.0](https://github.com/open-policy-agent/conftest/releases/tag/v0.25.0) (released on 2021-05-08) -1. Istio: [1.12.2](https://github.com/istio/istio/releases/tag/1.12.2) (released on 2022-01-19) +1. ArgoCD: [v2.8.4](https://github.com/argoproj/argo-cd/releases/tag/v2.8.4) +1. Prometheus-Operator: [v0.43.1](https://github.com/prometheus-operator/prometheus-operator/releases/tag/v0.43.1) +1. Prometheus: [latest](https://github.com/prometheus/prometheus/releases) +1. Grafana: [latest](https://github.com/grafana/grafana/releases) +1. Strimzi: [0.24.0](https://github.com/strimzi/strimzi-kafka-operator/releases/tag/0.24.0) +1. Kind: [v0.17.0](https://github.com/kubernetes-sigs/kind/releases/tag/v0.17.0) +1. Ingress Nginx Controller: [controller-v1.7.0](https://github.com/kubernetes/ingress-nginx/releases/tag/controller-v1.7.0) +1. Conftest: [v0.25.0](https://github.com/open-policy-agent/conftest/releases/tag/v0.25.0) +1. Istio: [1.19.0](https://github.com/istio/istio/releases/tag/1.19.0) 1. PostgresOperator: [v1.7.1](https://github.com/zalando/postgres-operator/releases/tag/v1.7.1) (released on 2021-11-04) 1. Cert Manager: [v1.7.1](https://github.com/cert-manager/cert-manager/releases/tag/v1.7.1) (released on 2022-02-05) diff --git a/contents/istio/README.md b/contents/istio/README.md index 8db79b7f..fac7ea98 100644 --- a/contents/istio/README.md +++ b/contents/istio/README.md @@ -17,10 +17,128 @@ Istio uses [Envoy](https://www.envoyproxy.io/), *AN OPEN SOURCE EDGE AND SERVICE CRDs and their roles -1. `DestinationRule` -1. `Gateway` (Istio) -1. `Gateway` (Networking) -1. `VirtualService` +1. [VirtualService](https://istio.io/latest/docs/concepts/traffic-management/#virtual-services): along with destination rules, the key building blocks of Istioโ€™s traffic routing functionality (e.g. routing to a specific version based on the request header, A/B testing, Canary release). `hosts`, `http`([match](https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPMatchRequest) and `route`) +
example + + ```yaml + apiVersion: networking.istio.io/v1alpha3 + kind: VirtualService + metadata: + name: bookinfo + spec: + hosts: + - bookinfo.com # can be ip address, DNS, kubernetes service short name + http: + - match: + - uri: + prefix: /reviews + route: + - destination: + host: reviews + - match: + - uri: + prefix: /ratings + route: + - destination: + host: ratings + ``` + +
+ +
example with weight (A/B testing and canary rollouts) + + ```yaml + spec: + hosts: + - reviews + http: + - route: + - destination: + host: reviews + subset: v1 + weight: 75 + - destination: + host: reviews + subset: v2 + weight: 25 + ``` + +
+ +1. [DestinationRule](https://istio.io/latest/docs/concepts/traffic-management/#destination-rules): use destination rules to configure what happens to traffic for that destination. Destination rules are applied **after** virtual service routing rules are evaluated. specify named service **`subsets`** (Ref [Destination Rule](https://istio.io/latest/docs/reference/config/networking/destination-rule/)) + +
example + + ```yaml + apiVersion: networking.istio.io/v1alpha3 + kind: DestinationRule + metadata: + name: my-destination-rule + spec: + host: my-svc + trafficPolicy: + loadBalancer: + simple: RANDOM + subsets: + - name: v1 + labels: + version: v1 + - name: v2 + labels: + version: v2 + trafficPolicy: + loadBalancer: + simple: ROUND_ROBIN + - name: v3 + labels: + version: v3 + ``` + +
+ +1. [Gateway](https://istio.io/latest/docs/concepts/traffic-management/#gateways) (Istio): manage inbound and outbound traffic for your mesh. Gateway configurations are applied to standalone Envoy proxies that are running at the edge of the mesh, rather than sidecar Envoy proxies running alongside your service workloads. Istio provides some preconfigured gateway proxy deployments (`istio-ingressgateway` and `istio-egressgateway`). **You also need to bind the gateway to a virtual service.** +
example + + ```yaml + apiVersion: networking.istio.io/v1alpha3 + kind: Gateway + metadata: + name: ext-host-gwy + spec: + selector: + app: my-gateway-controller + servers: + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - ext-host.example.com + tls: + mode: SIMPLE + credentialName: ext-host-cert + ``` + + specify routing + + ```yaml + apiVersion: networking.istio.io/v1alpha3 + kind: VirtualService + metadata: + name: virtual-svc + spec: + hosts: + - ext-host.example.com + gateways: + - ext-host-gwy + ``` + +
+1 [ServiceEntry](https://istio.io/latest/docs/concepts/traffic-management/#service-entries): Configuring service entries allows you to **manage traffic for services running outside of the mesh.** (ref: [Service Entry](https://istio.io/latest/docs/reference/config/networking/service-entry/)) +1. [Sidecar](https://istio.io/latest/docs/concepts/traffic-management/#sidecars) +1. `Gateway` (Kubernetes Gateway API): To overcome Ingress's shortcomings with a standard Kubernetes API (beta). You can consider migration of ingress traffic from Kubernetes Ignress or Gateway/VirtualService to the new Gateway API. (e.g. **Istio Implementation of the Gateway API**) Ref: [Getting started with the Kubernetes Gateway API](https://istio.io/latest/blog/2022/getting-started-gtwapi/) + Configure with **Gateway** in `gateway.networking.k8s.io/v1beta1` and `HTTPRoute` + ## [Getting Started](https://istio.io/latest/docs/setup/getting-started/) @@ -28,10 +146,10 @@ CRDs and their roles **If you test on your local cluster, pleasee use docker-desktop, minikube, or kind.** -1. `kind`: Istio Gateway might not work +1. [kind](../local-cluster/kind): Istio Gateway might not work ``` - kind create cluster --config=kind-config.yaml + kind create cluster --config=../local-cluster/kind/cluster-with-port-mapping.yaml ``` 1. `minikube`: Confirmed everything works ``` @@ -43,8 +161,9 @@ CRDs and their roles 1. Install `istioctl` (you can skip this step if you already installed `istioctl`) ``` - curl -L https://istio.io/downloadIstio | sh - - export PATH="$PATH:/Users/m.naka/repos/nakamasato/kubernetes-training/contents/istio/istio-1.18.2/bin" + ISTIO_VERSION=1.19.0 + curl -L https://istio.io/downloadIstio | ISTIO_VERSION=$ISTIO_VERSION sh - + export PATH="$PATH:/$PWD/istio-${ISTIO_VERSION}/bin" ``` Check istioctl version @@ -52,7 +171,7 @@ CRDs and their roles ``` istioctl version no ready Istio pods in "istio-system" - 1.18.2 + 1.19.0 ``` 1. Install istio @@ -107,7 +226,7 @@ CRDs and their roles 1. Deploy sample app ``` - kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/platform/kube/bookinfo.yaml + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/platform/kube/bookinfo.yaml ``` Deployed resources: @@ -167,7 +286,7 @@ CRDs and their roles 1. Istio Gateway (`Gateway` and `VirtualService` (`networking.istio.io/v1alpha3`)) ``` - kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/networking/bookinfo-gateway.yaml + kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/networking/bookinfo-gateway.yaml ```
yaml details @@ -221,7 +340,7 @@ CRDs and their roles
- Alternatively, `kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/gateway-api/bookinfo-gateway.yaml` to install (`Gateway` and `HTTPRoute` in `gateway.networking.k8s.io/v1beta1`) + Alternatively, `kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/gateway-api/bookinfo-gateway.yaml` to install (`Gateway` and `HTTPRoute` in `gateway.networking.k8s.io/v1beta1`) 1. Check ``` @@ -270,7 +389,7 @@ CRDs and their roles ![](docs/sample-app.png) - TODO: You might not be able to open it when `EXTERNAL-IP` is ``. + TODO: You might not be able to open it when `EXTERNAL-IP` is `` (this happens when using `kind`). ### [Define the service versions](https://istio.io/latest/docs/examples/bookinfo/#define-the-service-versions) @@ -280,7 +399,7 @@ Before you can use Istio to control the Bookinfo version routing, you need to de Create `DestinationRule` for each service `productpage`, `reviews`, `ratings` and `details`. ``` -kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/networking/destination-rule-all.yaml +kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/networking/destination-rule-all.yaml ``` ```yaml @@ -326,7 +445,7 @@ For more details, please check https://github.com/kubernetes-sigs/gateway-api #### Route to version 1 ``` -kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/networking/virtual-service-all-v1.yaml +kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/networking/virtual-service-all-v1.yaml ``` ```yaml @@ -351,7 +470,7 @@ spec: > Istio also supports routing based on strongly authenticated JWT on ingress gateway, refer to the JWT claim based routing for more details. ``` -kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml +kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml ``` ```yaml @@ -391,7 +510,7 @@ What's done? 1. Install [kiali](https://istio.io/latest/docs/ops/integrations/kiali/) dashboard ``` - for f in https://raw.githubusercontent.com/istio/istio/release-1.18/samples/addons/{grafana,jaeger,kiali,loki,prometheus}.yaml; do kubectl apply -f $f; done + for f in https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/addons/{grafana,jaeger,kiali,loki,prometheus}.yaml; do kubectl apply -f $f; done kubectl rollout status deployment/kiali -n istio-system ``` @@ -408,9 +527,9 @@ What's done? ### Cleanup ```bash -for f in https://raw.githubusercontent.com/istio/istio/release-1.18/samples/addons/{grafana,jaeger,kiali,loki,prometheus}.yaml; do kubectl delete -f $f; done # delete kilia -kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/networking/bookinfo-gateway.yaml # delete gateway -kubectl delete -f kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/bookinfo/platform/kube/bookinfo.yaml # delete application +for f in https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/addons/{grafana,jaeger,kiali,loki,prometheus}.yaml; do kubectl delete -f $f; done # delete kilia +kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/networking/bookinfo-gateway.yaml # delete gateway +kubectl delete -f kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${ISTIO_VERSION%.*}/samples/bookinfo/platform/kube/bookinfo.yaml # delete application istioctl manifest generate --set profile=demo | kubectl delete --ignore-not-found=true -f - # delete istio istioctl tag remove default ``` diff --git a/contents/istio/kind-config.yaml b/contents/istio/kind-config.yaml deleted file mode 100644 index 89ded6b2..00000000 --- a/contents/istio/kind-config.yaml +++ /dev/null @@ -1,17 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: - - role: control-plane - kubeadmConfigPatches: - - | - kind: InitConfiguration - nodeRegistration: - kubeletExtraArgs: - node-labels: "ingress-ready=true" - extraPortMappings: - - containerPort: 80 - hostPort: 80 - protocol: TCP - - containerPort: 443 - hostPort: 443 - protocol: TCP diff --git a/contents/kubernetes-operator/apimachinery/scheme/main_test.go b/contents/kubernetes-operator/apimachinery/scheme/main_test.go index 30e6381c..97802395 100644 --- a/contents/kubernetes-operator/apimachinery/scheme/main_test.go +++ b/contents/kubernetes-operator/apimachinery/scheme/main_test.go @@ -1,8 +1,8 @@ package main import ( - "testing" scheme "github.com/nakamasato/kubernetes-training/contents/kubernetes-operator/apimachinery/scheme/scheme" + "testing" ) func TestScheme(t *testing.T) { diff --git a/contents/local-cluster/README.md b/contents/local-cluster/README.md index 3e7f5141..ea440b03 100644 --- a/contents/local-cluster/README.md +++ b/contents/local-cluster/README.md @@ -1,5 +1,5 @@ # Local Kubernetes - Docker for Mac -- Minikube +- [Minikube](minikube) - [kind](kind) diff --git a/contents/local-cluster/kind/README.md b/contents/local-cluster/kind/README.md index 79f51d17..8e3b4c8f 100644 --- a/contents/local-cluster/kind/README.md +++ b/contents/local-cluster/kind/README.md @@ -7,16 +7,12 @@ kind is a tool for running local Kubernetes clusters using Docker container โ€œn ## Prerequisite - go (1.11+) - ``` - go version - go version go1.16.6 darwin/amd64 - ``` - Docker ## Quick Start ``` -GO111MODULE="on" go get sigs.k8s.io/kind@v0.10.0 && kind create cluster +kind create cluster ``` ## Installation @@ -31,7 +27,7 @@ brew install kind ``` kind version -kind v0.11.1 go1.16.4 darwin/amd64 +kind v0.20.0 go1.20.5 darwin/amd64 ``` ## Configure a cluster @@ -40,7 +36,7 @@ kind v0.11.1 go1.16.4 darwin/amd64 kind create cluster --config .yaml ``` -Example 1: enable alpha feature https://kind.sigs.k8s.io/docs/user/configuration/#feature-gates (https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/) +### Example 1: enable alpha feature https://kind.sigs.k8s.io/docs/user/configuration/#feature-gates (https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/) ``` kind create cluster --config cluster-with-alpha-feature.yaml @@ -59,6 +55,32 @@ kubectl cluster-info --context kind-kind Have a nice day! ๐Ÿ‘‹ ``` +### Example2: Port Mapping on MacOS + +``` +kind create cluster --config cluster-with-port-mapping.yaml +``` + +``` +kind create cluster --config=kind-config.yaml +Creating cluster "kind" ... + โœ“ Ensuring node image (kindest/node:v1.27.3) ๐Ÿ–ผ + โœ— Preparing nodes ๐Ÿ“ฆ +Deleted nodes: ["kind-control-plane"] +ERROR: failed to create cluster: command "docker run --name kind-control-plane --hostname kind-control-plane --label io.x-k8s.kind.role=control-plane --privileged --security-opt seccomp=unconfined --security-opt apparmor=unconfined --tmpfs /tmp --tmpfs /run --volume /var --volume /lib/modules:/lib/modules:ro -e KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER --detach --tty --label io.x-k8s.kind.cluster=kind --net kind --restart=on-failure:1 --init=false --cgroupns=private --publish=127.0.0.1:80:80/TCP --publish=127.0.0.1:443:443/TCP --publish=127.0.0.1:64460:6443/TCP -e KUBECONFIG=/etc/kubernetes/admin.conf kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72" failed with error: exit status 125 +Command Output: 652292163c0d7eab803a99ab16a89f1c2a32061f484cad28829883f164d036b8 +docker: Error response from daemon: Ports are not available: exposing port TCP 127.0.0.1:443 -> 0.0.0.0:0: not allowed as current user. +You can enable privileged port mapping from Docker -> Settings... -> Advanced -> Enable privileged port mapping. +``` + +If you encounter the above error, you can change the Docker's CLI tools: + +![](docker-cli-tool-config.png) + +Ref: +1. https://sumito.jp/2023/06/23/error-response-from-daemon-ports-are-not-available-exposing-port-tcp-127-0-0-180-0-0-0-00-not-allowed-as-current-user-you-can-enable-privileged-port-mapping-from-docker-settings-adva/ +1. https://kind.sigs.k8s.io/docs/user/configuration/#extra-port-mappings + ## Why kind? - kind supports multi-node (including HA) clusters diff --git a/contents/local-cluster/kind/cluster-with-port-mapping.yaml b/contents/local-cluster/kind/cluster-with-port-mapping.yaml new file mode 100644 index 00000000..fcddc06e --- /dev/null +++ b/contents/local-cluster/kind/cluster-with-port-mapping.yaml @@ -0,0 +1,23 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + # port forward 80 on the host to 80 on this node + extraPortMappings: + - containerPort: 80 + hostPort: 80 + # optional: set the bind address on the host + # 0.0.0.0 is the current default + listenAddress: "127.0.0.1" + # optional: set the protocol to one of TCP, UDP, SCTP. + # TCP is the default + protocol: TCP + - containerPort: 443 + hostPort: 443 + # optional: set the bind address on the host + # 0.0.0.0 is the current default + listenAddress: "127.0.0.1" + # optional: set the protocol to one of TCP, UDP, SCTP. + # TCP is the default + protocol: TCP +# from https://kind.sigs.k8s.io/docs/user/configuration/#extra-port-mappings diff --git a/contents/local-cluster/kind/docker-cli-tool-config.png b/contents/local-cluster/kind/docker-cli-tool-config.png new file mode 100644 index 00000000..3855b9be Binary files /dev/null and b/contents/local-cluster/kind/docker-cli-tool-config.png differ diff --git a/contents/local-cluster/minikube/README.md b/contents/local-cluster/minikube/README.md new file mode 100644 index 00000000..1f19eed1 --- /dev/null +++ b/contents/local-cluster/minikube/README.md @@ -0,0 +1,15 @@ +# [Minikube](https://minikube.sigs.k8s.io/docs/) + +## [Install](https://minikube.sigs.k8s.io/docs/start/) + + +``` +curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 +sudo install minikube-darwin-amd64 /usr/local/bin/minikube +``` + +## Start + +``` +minikube start +``` diff --git a/go.mod b/go.mod index 784d59cf..b25f8943 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/nakamasato/kubernetes-training -go 1.19 +go 1.20 require ( github.com/nakamasato/mysql-operator v0.3.3 diff --git a/readme.go b/readme.go index 578a17d7..f3705450 100644 --- a/readme.go +++ b/readme.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "strings" "github.com/nakamasato/kubernetes-training/doc" yaml "gopkg.in/yaml.v3" @@ -11,35 +12,38 @@ import ( func main() { - f, err := os.Open("readme.yml") - if err != nil { - log.Fatal(err) - } - defer f.Close() + f, err := os.Open("readme.yml") + if err != nil { + log.Fatal(err) + } + defer f.Close() - d := yaml.NewDecoder(f) + d := yaml.NewDecoder(f) - var m map[string][]Version + var m map[string][]Version - if err := d.Decode(&m); err != nil { - log.Fatal(err) - } + if err := d.Decode(&m); err != nil { + log.Fatal(err) + } generateReadme(m["versions"], "README.md") + + updateVersionInReadme(m["versions"], "contents/README.md") } type Version struct { - Name string `yaml:"name"` - Version string `yaml:"version"` - RepoUrl string `yaml:"repoUrl"` + Name string `yaml:"name"` + Version string `yaml:"version"` + RepoUrl string `yaml:"repoUrl"` Category string `yaml:"category"` - ToDo bool `yaml:"todo"` + ToDo bool `yaml:"todo"` + Dir string `yaml:"dir"` } func (v Version) getReleaseUrl() string { - if (v.Version == "") { + if v.Version == "" { return v.RepoUrl - } else if (v.Version == "latest") { + } else if v.Version == "latest" { return v.RepoUrl + "/releases" } else { return v.RepoUrl + "/releases/tag/" + v.Version @@ -47,7 +51,7 @@ func (v Version) getReleaseUrl() string { } func (v Version) getToDoString() string { - if (v.ToDo) { + if v.ToDo { return "(ToDo)" } else { return "" @@ -93,3 +97,35 @@ func generateReadme(versions []Version, filename string) { log.Fatal(err) } } + +func updateVersionInReadme(versions []Version, filename string) { + input, err := os.ReadFile(filename) + if err != nil { + log.Fatalln(err) + } + + lines := strings.Split(string(input), "\n") + + for _, version := range versions { + for i, line := range lines { + if strings.Contains(line, "Contents") { // not update Contents + break + } + if strings.Contains(line, fmt.Sprintf("1. %s:", version.Name)) { + lines[i] = fmt.Sprintf( + "1. %s: [%s](%s)%s", + version.Name, + version.Version, + version.getReleaseUrl(), + version.getToDoString(), + ) + break + } + } + } + output := strings.Join(lines, "\n") + err = os.WriteFile(filename, []byte(output), 0644) + if err != nil { + log.Fatalln(err) + } +} diff --git a/readme.yml b/readme.yml index e7f28e82..47402f77 100644 --- a/readme.yml +++ b/readme.yml @@ -22,10 +22,12 @@ versions: version: v0.43.1 repoUrl: https://github.com/prometheus-operator/prometheus-operator category: Monitoring + dir: prometheus-operator - name: Prometheus version: "latest" repoUrl: https://github.com/prometheus/prometheus category: Monitoring + dir: prometheus - name: Grafana version: "latest" repoUrl: https://github.com/grafana/grafana @@ -64,7 +66,7 @@ versions: repoUrl: https://github.com/open-policy-agent/conftest category: CI/CD - name: Istio - version: 1.18.2 + version: 1.19.0 repoUrl: https://github.com/istio/istio category: Service Proxy, Discovery, and, Mesh - name: Postgres Operator @@ -82,6 +84,7 @@ versions: version: null repoUrl: https://github.com/elastic/cloud-on-k8s category: Middleware (Operator) + dir: eck - name: Kyverno version: null repoUrl: https://github.com/kyverno/kyverno