snapshotter

package module
v0.0.0-...-5bcadfd Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 12 Imported by: 2

README

Description

This library allows kubernetes pod on Google Cloud (gke), with proper permissions, to trigger a snapshot

kubernetes permissions

For each namespace:

  1. create a clusterrole (clusterwide) that gives:
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: system:controller:pv-protection-controller
    
to:

subjects:

  • kind: ServiceAccount name: podreader namespace: ...

2) create a role (in namespace) that gives GET to pods,pvc,pv:
  • apiGroups:
    • '*' resources:
    • pods
    • persistentvolumeclaims
    • persistentvolumes verbs:
    • get

3) create a serviceaccount (in that namespace) with a clear name

4) create a rolebinding (in that namespace) for that "Role" to that "ServiceAccount"

roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: podread subjects:

  • kind: ServiceAccount name: podreader

## GCP permissions ##

* You will need a custom role for creating snapshots, and associate that role to the serviceaccount used by this pod (through ENV vars and stuff...)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvConfig = newConfig()

Functions

func GenerateName

func GenerateName(namespace, appNameVer string, lastSeenBlockNum uint32) string

func InsertPVFromSnapshot

func InsertPVFromSnapshot(ctx context.Context, logger *zap.Logger, snapshot *compute.Snapshot, namePrefix, zone string) (out *compute.Disk, err error)

func ListSnapshots

func ListSnapshots(ctx context.Context) (out []*compute.Snapshot, err error)

func TakeSnapshot

func TakeSnapshot(ctx context.Context, snapshotName, project, namespace, pod, prefix string, archive bool) error

func TakeSnapshotFromEnv

func TakeSnapshotFromEnv(ctx context.Context, snapshotName string) error

Types

type Config

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

func (*Config) Valid

func (c *Config) Valid() error

type GKEPVCSnapshotter

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

func NewGKEPVCSnapshotter

func NewGKEPVCSnapshotter(conf map[string]string) (*GKEPVCSnapshotter, error)

func (*GKEPVCSnapshotter) Backup

func (s *GKEPVCSnapshotter) Backup(lastSeenBlockNum uint32) (string, error)

func (*GKEPVCSnapshotter) RequiresStop

func (s *GKEPVCSnapshotter) RequiresStop() bool

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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