Snapshot of Hostpath volume in kubernetes example clarification

4/22/2019

I have a K8s cluster inside Azure VMs, running Ubuntu 18. Cluster was provisioned using conjure-up.

I am trying to test the kubernetes snapshot feature. Trying to follow the steps here: https://github.com/kubernetes-incubator/external-storage/blob/master/snapshot/doc/examples/hostpath/README.md

While i can follow most instructions on the page, not sure of what this specific command does:

"_output/bin/snapshot-controller  -kubeconfig=${HOME}/.kube/config"

directly executing this instruction doesnt work as such.

Can anyone explain what this does and how to run this part successfully? Or better yet point to a complete walk-through if it exists.


Update

Tried out steps from https://github.com/kubernetes-incubator/external-storage/tree/master/snapshot/deploy/kubernetes/hostpath

Commented out below line since not using RBAC

# serviceAccountName: snapshot-controller-runner

Then deployed using

kubectl create -f deployment.yaml

kubectl create -f pv.yaml

kubectl create -f pvc.yaml

kubectl create -f snapshot.yaml

These yaml are from examples 'as is':

github.com/kubernetes-incubator/external-storage/blob/master/snapshot/doc/examples/hostpath/

kubectl describe volumesnapshot snapshot-demo             Name:         snapshot-demo
Namespace:    default
Labels:       SnapshotMetadata-PVName=hostpath-pv
              SnapshotMetadata-Timestamp=1555999582450832931
Annotations:  <none>
API Version:  volumesnapshot.external-storage.k8s.io/v1
Kind:         VolumeSnapshot
Metadata:
  Creation Timestamp:  2019-04-23T05:56:05Z
  Generation:          2
  Resource Version:    261433
  Self Link:           /apis/volumesnapshot.external-storage.k8s.io/v1/namespaces/default/volumesnapshots/snapshot-demo
  UID:                 7b89194a-658c-11e9-86b2-000d3a07ff79
Spec:
  Persistent Volume Claim Name:  hostpath-pvc
  Snapshot Data Name:
Status:
  Conditions:          <nil>
  Creation Timestamp:  <nil>
Events:                <none>

the snapshot resource is created however the volumesnapshotdata is NOT created.

kubectl get volumesnapshotdata
No resources found.
kubectl get crd
NAME                                                         CREATED AT
volumesnapshotdatas.volumesnapshot.external-storage.k8s.io   2019-04-21T04:18:54Z
volumesnapshots.volumesnapshot.external-storage.k8s.io       2019-04-21T04:18:54Z
kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
azure                                  1/1     Running   2          2d21h
azure-2                                1/1     Running   2          2d20h
snapshot-controller-5d798696ff-qsh6m   2/2     Running   2          14h

ls /tmp/test/
data

Enabled featuregate for volume snapshot

cat /var/snap/kube-apiserver/924/args

--advertise-address="192.168.0.4"
--min-request-timeout="300"
--etcd-cafile="/root/cdk/etcd/client-ca.pem"
--etcd-certfile="/root/cdk/etcd/client-cert.pem"
--etcd-keyfile="/root/cdk/etcd/client-key.pem"
--etcd-servers="https://192.168.0.4:2379"
--storage-backend="etcd3"
--tls-cert-file="/root/cdk/server.crt"
--tls-private-key-file="/root/cdk/server.key"
--insecure-bind-address="127.0.0.1"
--insecure-port="8080"
--audit-log-maxbackup="9"
--audit-log-maxsize="100"
--audit-log-path="/root/cdk/audit/audit.log"
--audit-policy-file="/root/cdk/audit/audit-policy.yaml"
--basic-auth-file="/root/cdk/basic_auth.csv"
--client-ca-file="/root/cdk/ca.crt"
--requestheader-allowed-names="system:kube-apiserver"
--requestheader-client-ca-file="/root/cdk/ca.crt"
--requestheader-extra-headers-prefix="X-Remote-Extra-"
--requestheader-group-headers="X-Remote-Group"
--requestheader-username-headers="X-Remote-User"
--service-account-key-file="/root/cdk/serviceaccount.key"
--token-auth-file="/root/cdk/known_tokens.csv"
--authorization-mode="AlwaysAllow"
--admission-control="NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
--allow-privileged=true
--enable-aggregator-routing
--kubelet-certificate-authority="/root/cdk/ca.crt"
--kubelet-client-certificate="/root/cdk/client.crt"
--kubelet-client-key="/root/cdk/client.key"
--kubelet-preferred-address-types="[InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP]"
--proxy-client-cert-file="/root/cdk/client.crt"
--proxy-client-key-file="/root/cdk/client.key"
--service-cluster-ip-range="10.152.183.0/24"
--logtostderr
--v="4"
--feature-gates="VolumeSnapshotDataSource=true"

What am i missing here?

-- Sumesh
kubernetes

1 Answer

4/22/2019

I think everything you need is already present here: https://github.com/kubernetes-incubator/external-storage/tree/master/snapshot/deploy/kubernetes/hostpath

There is one YAML for deployment of snapshot controller and one YAML for snapshotter RBAC rules.

-- Vasily Angapov
Source: StackOverflow