Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

feat: add usage metrics #2482

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ builds:
- -s
- -w
- -X "github.com/acorn-io/runtime/pkg/version.Tag=v{{ .Version }}"
- -X 'github.com/acorn-io/runtime/pkg/usage.BaseURL="{{ .Env.USAGE_METRICS_URL }}"

universal_binaries:
- id: mac
Expand Down
1 change: 1 addition & 0 deletions docs/docs/100-reference/01-command-line/acorn_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ acorn install
--controller-memory string The memory to allocate to the runtime-controller in the format of <req>:<limit> (example 256Mi:1Gi)
--controller-replicas int acorn-controller deployment replica count
--controller-service-account-annotation strings annotation to apply to the acorn-system service account
--disable-usage-metrics Disable usage metrics collection (default is false)
--event-ttl string Amount of time an Acorn event will be stored before being deleted (default '168h' - 7 days)
--features strings Enable or disable features. (example foo=true,bar=false)
-h, --help help for install
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Options

## Acorn image

When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Options

## Acorn image

When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-0.3/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from an private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from an private registry.

## TLS via Let's Encrypt

Expand Down Expand Up @@ -40,4 +40,4 @@ Acorn provides several installation options for controlling the domain name used
Acorn [requires an ingress controller](01-installing.md#ingress-and-service-loadbalancers) to function properly. If your cluster has more than one ingress controller or if it has one but it isn't set as the [default](https://kubernetes.io/docs/concepts/services-networking/ingress/#default-ingress-class), you can explicitly set the ingress class using `--ingress-class-name`.

## Changing install options
If you want to change your install options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
If you want to change your install options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.3/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-0.4/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down Expand Up @@ -36,4 +36,4 @@ Acorn provides several installation options for controlling the domain name used
Acorn [requires an ingress controller](01-installing.md#ingress-and-service-loadbalancers) to function properly. If your cluster has more than one ingress controller or if it has one but it isn't set as the [default](https://kubernetes.io/docs/concepts/services-networking/ingress/#default-ingress-class), you can explicitly set the ingress class using `--ingress-class-name`.

## Changing install options
If you want to change your install options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
If you want to change your install options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.4/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-0.5/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down Expand Up @@ -91,4 +91,4 @@ Note that in order to allow propagation of user-defined labels and annotations o


## Changing install options
If you want to change your installation options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
If you want to change your installation options after the initial installation, just rerun `acorn install` with the new options. This will update the existing install dynamically.
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.5/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-0.6/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down Expand Up @@ -101,4 +101,4 @@ For strings array flags, you can reset the slice to empty by pass empty string "

```bash
acorn install --propagate-project-annotation ""
```
```
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.6/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-0.7/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down Expand Up @@ -134,4 +134,4 @@ For strings array flags, you can reset the slice to empty by pass empty string "

```bash
acorn install --propagate-project-annotation ""
```
```
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.7/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.8/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ acorn info
# publicKeys:
# - keyID: 3rRkDpFF9FjhT4wGTaIvw8U5MX0p80eosk8yu61FOAY
#server:
# apiServerImage: ghcr.io/acorn-io/runtime:main
# apiServerImage: images.acornlabs.com/acorn-io/runtime:main
# config:
#....
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Options
---

## Acorn image
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `ghcr.io/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.
When you install acorn, it will launch several workloads in your cluster, including an api-server and controller. By default, these workloads will use the `images.acornlabs.com/acorn-io/runtime` image. You can customize this image by setting the `--image` option. This is useful if you are installing acorn in an environment where you are required to pull images from a private registry.

## TLS via Let's Encrypt

Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-0.9/39-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To publish your image run the familiar build command with a `-t` option to tag t
An example would be:

```shell
acorn build -t ghcr.io/acorn-io/runtime:v1.0 .
acorn build -t images.acornlabs.com/acorn-io/runtime:v1.0 .
```

This is very similar to the Docker build workflow:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/api.acorn.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ type Config struct {
RegistryCPU *string `json:"registryCPU" name:"registry-cpu" usage:"The CPU to allocate to the registry in the format of <req>:<limit> (example 200m:1000m)"`
IgnoreResourceRequirements *bool `json:"ignoreResourceRequirements" name:"ignore-resource-requirements" usage:"Ignore memory and CPU requests and limits, intended for local development (default is false)"`
RequireComputeClass *bool `json:"requireComputeClass" name:"require-compute-class" usage:"Require applications to have a Compute Class set (default is false)"`

// Usage Metrics
DisableUsageMetrics *bool `json:"disableUsageMetrics" name:"disable-usage-metrics" usage:"Disable usage metrics collection (default is false)"`
}

type EncryptionKey struct {
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/api.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func complete(ctx context.Context, c *apiv1.Config, getter kclient.Reader, inclu
if c.AutoConfigureKarpenterDontEvictAnnotations == nil {
c.AutoConfigureKarpenterDontEvictAnnotations = profile.AutoConfigureKarpenterDontEvictAnnotations
}
if c.DisableUsageMetrics == nil {
c.DisableUsageMetrics = profile.DisableUsageMetrics
}
return nil
}

Expand Down Expand Up @@ -471,6 +474,9 @@ func merge(oldConfig, newConfig *apiv1.Config) *apiv1.Config {
if newConfig.AutoConfigureKarpenterDontEvictAnnotations != nil {
mergedConfig.AutoConfigureKarpenterDontEvictAnnotations = newConfig.AutoConfigureKarpenterDontEvictAnnotations
}
if newConfig.DisableUsageMetrics != nil {
mergedConfig.DisableUsageMetrics = newConfig.DisableUsageMetrics
}

return &mergedConfig
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/acorn-io/runtime/pkg/logserver"
"github.com/acorn-io/runtime/pkg/scheme"
"github.com/acorn-io/runtime/pkg/system"
"github.com/acorn-io/runtime/pkg/usage"
"github.com/acorn-io/runtime/pkg/version"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -115,6 +117,8 @@ func (c *Controller) Start(ctx context.Context) error {

logserver.StartServerWithDefaults()

go usage.Heartbeat(ctx, c.client, usage.ComponentController, 24*time.Hour, version.Get().String())

// Every 5 minutes, delete EventInstances until only the most recent 1000 remain.
// Use c.Router.Backend() to ensure we hit the cache when possible.
// Note: the cache will only be populated for EventInstances if a handler for EventInstances has been registered.
Expand Down
2 changes: 1 addition & 1 deletion pkg/install/apiserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
spec:
containers:
- name: acorn-api
image: ghcr.io/acorn-io/runtime
image: images.acornlabs.com/acorn-io/runtime
args:
- api-server
ports:
Expand Down
2 changes: 1 addition & 1 deletion pkg/install/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
spec:
containers:
- name: acorn-controller
image: ghcr.io/acorn-io/runtime
image: images.acornlabs.com/acorn-io/runtime
env:
- name: LEGO_DISABLE_CNAME_SUPPORT
value: "true"
Expand Down
5 changes: 5 additions & 0 deletions pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/acorn-io/runtime/pkg/scheme"
"github.com/acorn-io/runtime/pkg/system"
"github.com/acorn-io/runtime/pkg/term"
"github.com/acorn-io/runtime/pkg/usage"
"github.com/acorn-io/runtime/pkg/version"
"github.com/acorn-io/z"
"github.com/pterm/pterm"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -308,6 +310,9 @@ func Install(ctx context.Context, image string, opts *Options) error {
if !opts.Quiet {
pterm.Success.Println("Installation done")
}

_ = usage.Pulse(ctx, c, usage.ComponentCLI, usage.ActionInstall, version.Get().String())

return nil
}

Expand Down
Loading
Loading