diff --git a/.gitignore b/.gitignore index 40b1504b..d799f29c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ k8sgpt-operator bin testbin/* Dockerfile.cross - +config/rendered # Test binary, build with `go test -c` *.test diff --git a/.helmignore b/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/Makefile b/Makefile index ae7e8648..76a36cab 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ IMG ?= ghcr.io/k8sgpt-ai/k8sgpt:latest # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.26.0 - +CHART_VERSION=v0.0.1# x-release-please-version # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) GOBIN=$(shell go env GOPATH)/bin @@ -73,11 +73,8 @@ run: manifests generate fmt vet ## Run a controller from your host. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build docker-build: test ## Build docker image with the manager. - docker build -t ${IMG} . - -.PHONY: docker-push -docker-push: ## Push docker image with the manager. - docker push ${IMG} + @echo "===========> Building docker image" + docker buildx build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} -f container/Dockerfile . --push # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: @@ -119,6 +116,26 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - +OSARCH=$(shell ./hack/get-os.sh) +HELM = $(shell pwd)/bin/$(OSARCH)/helm +HELM_INSTALLER ?= "https://get.helm.sh/helm-v3.10.1-$(OSARCH).tar.gz" +.PHONY: helm +helm: $(HELM) ## Download helm locally if necessary. +$(HELM): $(LOCALBIN) + [ -e "$(HELM)" ] && rm -rf "$(HELM)" || true + cd $(LOCALBIN) && curl -s $(HELM_INSTALLER) | tar -xzf - -C $(LOCALBIN) + +.PHONY: release-manifests +release-manifests: manifests kustomize + cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) && cd ../../ + mkdir -p chart/k8sgpt-operator/templates/ + $(KUSTOMIZE) build config/default > chart/k8sgpt-operator/templates/rendered.yaml + +helm-package: generate release-manifests helm + $(HELM) package --version $(CHART_VERSION) chart/k8sgpt-operator + mkdir -p charts && mv k8sgpt-operator-*.tgz charts + $(HELM) repo index --url https://charts.k8sgpt.ai/charts charts + mv charts/index.yaml index.yaml ##@ Build Dependencies ## Location to install dependencies to diff --git a/README.md b/README.md index 33df2136..9dd8413b 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ UnDeploy the controller from the cluster: make undeploy ``` +
+ Contributing + ## Contributing // TODO(user): Add detailed information on how you would like others to contribute to this project @@ -90,19 +93,4 @@ make manifests More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html) -## License - -Copyright 2023 K8sGPT Contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - +
diff --git a/charts/k8sgpt-operator-v0.0.1.tgz b/charts/k8sgpt-operator-v0.0.1.tgz new file mode 100644 index 00000000..fd74e266 Binary files /dev/null and b/charts/k8sgpt-operator-v0.0.1.tgz differ diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5c5f0b84..3d0276c1 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ resources: - manager.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ghcr.io/k8sgpt-ai/k8sgpt + newTag: latest diff --git a/hack/get-os.sh b/hack/get-os.sh new file mode 100755 index 00000000..2d1ef81a --- /dev/null +++ b/hack/get-os.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# initArch discovers the architecture for this system. +initArch() { + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5";; + armv6*) ARCH="armv6";; + armv7*) ARCH="arm";; + aarch64) ARCH="arm64";; + x86) ARCH="386";; + x86_64) ARCH="amd64";; + i686) ARCH="386";; + i386) ARCH="386";; + esac +} + +# initOS discovers the operating system for this system. +initOS() { + OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') + + case "$OS" in + # Minimalist GNU for Windows + mingw*|cygwin*) OS='windows';; + esac +} +initArch +initOS +echo "${OS}-${ARCH}" diff --git a/index.yaml b/index.yaml new file mode 100644 index 00000000..95afbb9e --- /dev/null +++ b/index.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +entries: + k8sgpt-operator: + - apiVersion: v2 + appVersion: 1.16.0 + created: "2023-04-24T13:56:45.649926+02:00" + description: A Helm chart for Kubernetes + digest: 7ac79873d450f5edb6a60b280940159a83ff4e9195afac86a9866fe61960cc3c + name: k8sgpt-operator + type: application + urls: + - https://k8sgpt-ai.github.io/k8sgpt-operator/charts/k8sgpt-operator-v0.0.1.tgz + version: v0.0.1 +generated: "2023-04-24T13:56:45.649593+02:00" diff --git a/values.yaml b/values.yaml new file mode 100644 index 00000000..e498bb7a --- /dev/null +++ b/values.yaml @@ -0,0 +1,82 @@ +# Default values for k8sgpt-operator. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}