Skip to content

Instantly share code, notes, and snippets.

View nrb's full-sized avatar
🤔

Nolan Brubaker nrb

🤔
View GitHub Profile
Name: nginx-deployment-99997d74d-j2qvh
Namespace: nginx-example
Node: gke-cluster-1-default-pool-0b8556a0-bcfx/10.150.0.2
Start Time: Thu, 21 Jun 2018 16:17:34 -0400
Labels: app=nginx
ark-restore=nginx-20180621161706
pod-template-hash=555538308
Annotations: backup.ark.heptio.com/backup-volumes=nginx-logs
snapshot.ark.heptio.com/nginx-logs=42cc95b1
Status: Pending
@nrb
nrb / _order-of-operations
Created June 21, 2018 20:08
restic backup hang
./_output/bin/linux/amd64/ark restic repo init nginx-example
./_output/bin/linux/amd64/ark restic repo change-key nginx-example
kubectl -n nginx-example annotate pod/nginx-deployment-99997d74d-j2qvh backup.ark.heptio.com/backup-volumes=nginx-logs
./_output/bin/linux/amd64/ark backup create nginx --include-namespaces nginx-example
# backup created, but hasn't been updated.
x1c in /home/nrb/go/src/github.com/heptio/ark (git) backup-timing U
% go test ./pkg/controller -run TestProcessBackup
--- FAIL: TestProcessBackup (0.01s)
--- FAIL: TestProcessBackup/make_sure_specified_included_and_excluded_resources_are_honored (0.00s)
Error Trace: comparisons.go:78
backup_controller_test.go:295
Error: Received unexpected error:
json: unknown field "completionTimestamp"
--- FAIL: TestProcessBackup/if_includednamespaces_are_specified,_don't_default_to_* (0.00s)
Error Trace: comparisons.go:78
% AWS_SHARED_CREDENTIALS_FILE=credentials-ark-aws ./_output/bin/linux/amd64/ark server --log-level debug
INFO[0000] setting log-level to DEBUG
INFO[0000] Starting Ark server v0.9.0-alpha.2-14-gf0e8c93-dirty logSource="pkg/cmd/server/server.go:100"
INFO[0000] Ensuring namespace exists for backups logSource="pkg/cmd/server/server.go:258" namespace=heptio-ark
INFO[0000] Namespace already exists logSource="pkg/cmd/server/server.go:270" namespace=heptio-ark
INFO[0000] Retrieving Ark configuration logSource="pkg/cmd/server/server.go:275"
INFO[0000] Successfully retrieved Ark configuration logSource="pkg/cmd/server/server.go:293"
INFO[0000] Using default resource priorities logSource="pkg/cmd/server/server.go:343" priorities="[namespaces persistentvolumes persistentvolumeclaims secrets configmaps serviceaccounts limitranges pods]"
INFO[0000] Configuring cloud provider for backup service logSource="pkg/cmd/server/server.go:392"
DEBU[0000] starting plugi
@nrb
nrb / ark-config.yaml
Last active June 19, 2018 17:26
Restic failures
apiVersion: ark.heptio.com/v1
backupStorageProvider:
bucket: <REDACTED>
config:
region: us-west-2
name: aws
resticLocation: <REDACTED>restic
backupSyncPeriod: 30m
gcSyncPeriod: 30m
kind: Config
type writeReadDeleter interface {
NewWriter(context.Context) io.WriteCloser
NewReader(context.Context) (io.ReadCloser, error)
Delete(context.Context) error
}
type objectIterator interface {
Next() (writeReadDeleter, error)
}
x1c in /home/nrb/go/src/github.com/heptio/ark (git) master U
% GOOGLE_APPLICATION_CREDENTIALS=credentials-ark-gke ./_output/bin/linux/amd64/ark server --plugin-dir ./_output/bin/linux/amd64 --log-level debug
INFO[0000] setting log-level to DEBUG
INFO[0000] Starting Ark server v0.8.1-58-gaeb5f6d-dirty logSource="pkg/cmd/server/server.go:95"
INFO[0000] Ensuring namespace exists for backups logSource="pkg/cmd/server/server.go:264" namespace=heptio-ark
INFO[0000] Namespace already exists logSource="pkg/cmd/server/server.go:276" namespace=heptio-ark
INFO[0000] Retrieving Ark configuration logSource="pkg/cmd/server/server.go:281"
INFO[0000] Successfully retrieved Ark configuration logSource="pkg/cmd/server/server.go:299"
INFO[0000] Using default resource priorities logSource="pkg/cmd/server/server.go:334" priorities="[namespaces persistentvolumes persistentvolumeclaims secrets configmaps serviceaccounts limitranges]"
INFO[0000] Configuring cloud provid
func (br *backupService) UploadBackup(bucket, backupName string, metadata, backup, log io.Reader) error {
// Uploading the log file is best-effort; if it fails, we log the error but it doesn't impact the
// backup's status.
logKey := getBackupLogKey(backupName, backupName)
if err := br.seekAndPutObject(bucket, logKey, log); err != nil {
br.logger.WithError(err).WithFields(logrus.Fields{
"bucket": bucket,
"key": logKey,
}).Error("Error uploading log file")
}
if groupResource == podsGroupResource {
metadata, err := meta.Accessor(obj)
if err != nil {
return err
}
fmt.Println("Found pod:", metadata.GetName())
phase, found, err := unstructured.NestedString(obj.UnstructuredContent(), "status.phase")
if err != nil {
return err
}
$ RESOURCES=$(kubectl get crd -o json | jq -r '.items | map(.spec.names.singular) | join(",")')
$ kubectl get $RESOURCES -n heptio-ark
$ echo $RESOURCES
backup,config,deletebackuprequest,downloadrequest,restore,schedule