Kubernetes示例澄清中的Hostpath卷快照

时间:2019-04-22 10:15:32

标签: kubernetes

我在运行Ubuntu Ubuntu 18的Azure VM中拥有一个K8s群集。 群集是使用召回配置的。

我正在尝试测试kubernetes快照功能。尝试按照此处的步骤操作: https://github.com/kubernetes-incubator/external-storage/blob/master/snapshot/doc/examples/hostpath/README.md

虽然我可以按照页面上的大多数说明进行操作,但不确定此特定命令的作用:

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

直接执行此指令无法正常工作。

任何人都可以解释它的作用以及如何成功运行此部分吗? 还是最好指向完整的演练(如果存在)。


更新

尝试了以下步骤 https://github.com/kubernetes-incubator/external-storage/tree/master/snapshot/deploy/kubernetes/hostpath

由于未使用RBAC,因此在行下方进行了注释

#serviceAccountName:快照控制器运行程序

然后使用

进行部署

kubectl create -f deployment.yaml

kubectl create -f pv.yaml

kubectl create -f pvc.yaml

kubectl创建-f snapshot.yaml

这些yaml来自“原样”示例:

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>

已创建快照资源,但未创建volumenapshotdata。

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

为卷快照启用了功能门

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"

我在这里想念什么?

1 个答案:

答案 0 :(得分:0)

我认为您所需的一切已经在这里:https://github.com/kubernetes-incubator/external-storage/tree/master/snapshot/deploy/kubernetes/hostpath

有一个用于部署快照控制器的YAML,一个用于快照程序RBAC规则的YAML。