usage

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package usage is responsible for reporting NGINX Plus usage data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectNodeCount

func CollectNodeCount(ctx context.Context, k8sClient client.Reader) (int, error)

CollectNodeCount returns the number of nodes in the cluster.

func CreateUsageJobWorker

func CreateUsageJobWorker(
	logger logr.Logger,
	k8sClient client.Reader,
	reporter Reporter,
	cfg config.Config,
) func(ctx context.Context)

func GetTotalNGFPodCount

func GetTotalNGFPodCount(ctx context.Context, k8sClient client.Reader) (int, error)

GetTotalNGFPodCount returns the total count of NGF Pods in the cluster. Uses the "app.kubernetes.io/name" label with either value of "nginx-gateway" or "nginx-gateway-fabric".

Types

type ClusterDetails

type ClusterDetails struct {
	// Metadata contains the cluster metadata.
	Metadata Metadata `json:"metadata"`
	// PodDetails contain the details about the NGF Pod.
	PodDetails PodDetails `json:"pod_details"`
	// NodeCount is the count of Nodes in the cluster.
	NodeCount int64 `json:"node_count"`
}

ClusterDetails are the k8s usage details for the cluster.

type CurrentPodsCount

type CurrentPodsCount struct {
	// PodCount is the current count of NGF NGINX Plus Pods in the cluster.
	PodCount int64 `json:"pod_count"`
	// DosCount is the count of Pods with NAP DOS enabled in the cluster. Not applicable for NGF,
	// but required as part of the payload.
	DosCount int64 `json:"dos_count"`
	// WafCount is the count of Pods with NAP WAF enabled in the cluster. Not applicable for NGF,
	// but required as part of the payload.
	WafCount int64 `json:"waf_count"`
}

CurrentPodsCount is the total count of NGF NGINX Plus Pods in the cluster.

type Metadata

type Metadata struct {
	// DisplayName is a user friendly resource name. It can be used to define
	// a longer, and less constrained, name for a resource.
	DisplayName string `json:"displayName"`
	// UID is the unique identifier for the cluster.
	UID string `json:"uid"`
}

Metadata contains the cluster metadata.

type NIMReporter

type NIMReporter struct {
	// contains filtered or unexported fields
}

NIMReporter reports the NGINX Plus usage info to NGINX Instance Manager.

func NewNIMReporter

func NewNIMReporter(
	credentials credentialsGetter,
	baseURL string,
	insecureSkipVerify bool,
) (*NIMReporter, error)

NewNIMReporter creates a new NIM usage reporter.

func (*NIMReporter) Report

func (r *NIMReporter) Report(ctx context.Context, data ClusterDetails) error

Report sends a PUT request with the provided data to the API endpoint configured in the Reporter. The clusterUID is used as the name in the API path.

type PodDetails

type PodDetails struct {
	// CurrentPodsCount is the total count of NGF NGINX Plus Pods in the cluster.
	CurrentPodCounts CurrentPodsCount `json:"current_pod_counts"`
}

PodDetails contain the details about the NGF Pod.

type Reporter

type Reporter interface {
	Report(context.Context, ClusterDetails) error
}

Reporter reports the NGINX Plus usage info to the provided collector.

type Secret

type Secret struct {
	// contains filtered or unexported fields
}

Secret implements the SecretStorer interface.

func NewUsageSecret

func NewUsageSecret() *Secret

NewUsageSecret creates a new Secret wrapper.

func (*Secret) Delete

func (s *Secret) Delete()

Delete nullifies the Secret value.

func (*Secret) GetCredentials

func (s *Secret) GetCredentials() ([]byte, []byte)

GetCredentials returns the base64 encoded username and password from the Secret.

func (*Secret) Set

func (s *Secret) Set(secret *v1.Secret)

Set stores the updated Secre.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL