utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 20 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCSRApprover added in v0.2.0

func DefaultCSRApprover(agentName string) agent.CSRApproveFunc

DefaultCSRApprover approve the csr when addon agent uses default group and default user to sign csr.

func DefaultSignerWithExpiry added in v0.2.0

func DefaultSignerWithExpiry(caKey, caData []byte, duration time.Duration) agent.CSRSignerFunc

DefaultSignerWithExpiry generates a signer func for addon agent to sign the csr using caKey and caData with expiry date.

func MergeRelatedObjects

func MergeRelatedObjects(modified *bool, objs *[]addonapiv1alpha1.ObjectReference, obj addonapiv1alpha1.ObjectReference)

func NewConfigChecker

func NewConfigChecker(name string, configfiles ...string) (*configChecker, error)

NewConfigChecker

Parameters: * name could be any string. * configfiles should be the same as your target container are using now.

There is two use cases: Case1: Embeding configchecker into the current server

In this case, we simply initialize a configchecker and add it to the current in used healthz.Checkers. You can check here for a reference: https://github.com/open-cluster-management/multicloud-operators-foundation/blob/56270b1520ec5896981db689b3afe0cd893cad8e/cmd/agent/agent.go#L148

-----------------------------------------------------------------------------

Case2: Using configchecker as an independent process to watch another service

Example Code: config_checker_server.go

type configCheckerServer struct {
	checkers []heathz.HealthChecker
}
func NewConfigCheckerServer(checkers []healthz.HealthChecker) *configCheckerServer {
	return &configCheckerServer{checkers: checkers}
}
func (s *configCheckerServer) ServerHttp(rw http.ResponseWriter, r *http.Request) {
	for _, c := range s.chekers {
		if c.Name() == r.URL {
			if err := c.Check(); err != nil {
				rw.WriteHeader(500)
			} else {
				rw.WriteHeader(200)
			}
		}
	}
}

main.go ... configchecker := utils.NewConfigChecker("checker", "/config/server-config.yaml") configchecker.SetReload(true) ccServer := NewConfigCheckerServer([]healthz.HealthChecker{configchecker}) ...

There are some watch-outs for this case: 1. One configchecker server for one target server, don't use one configchecker for multiple server. 2. Set `reload` to `true` by invoke `SetReload` function. 3. In deployment's livessProbe config, the `failureThreshold` must be `1`.

func UnionCSRApprover added in v0.2.0

func UnionCSRApprover(approvers ...agent.CSRApproveFunc) agent.CSRApproveFunc

UnionCSRApprover is a union func for multiple approvers

Types

This section is empty.

Jump to

Keyboard shortcuts

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