【问题标题】:Snapshot of Hostpath volume in kubernetes example clarificationKubernetes 示例说明中 Hostpath 卷的快照
【发布时间】:2019-09-11 13:11:39
【问题描述】:

我在 Azure VM 中有一个 K8s 集群,运行 Ubuntu 18。 集群是使用 conjure-up 配置的。

我正在尝试测试 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 create -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>

已创建快照资源,但未创建卷快照数据。

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"

我在这里错过了什么?

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    我想你需要的一切都已经在这里了:https://github.com/kubernetes-incubator/external-storage/tree/master/snapshot/deploy/kubernetes/hostpath

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

    【讨论】:

    • 感谢您的澄清。我已经尝试过上面更新的步骤,但是没有创建volumesnapshotdata。
    • 看起来我可能缺少启用功能门步骤。 --feature-gates=VolumeSnapshotDataSource=true 大多数在线可用说明都指向编辑 kubeadm 配置文件,这在我的情况下不适用。试图弄清楚如何在召唤部署中启用它。
    • 启用功能门 --feature-gates=VolumeSnapshotDataSource=true 。仍然快照不起作用。有什么线索吗?
    猜你喜欢
    • 2018-10-04
    • 2021-04-18
    • 2019-12-01
    • 1970-01-01
    • 2018-01-09
    • 2021-06-09
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多