由 SuKai April 8, 2022
今天我们一起来安装一下Clusterpedia,看看Clusterpedia的功能。
安装
Clusterpedia代码目录deploy下提供了kubectl安装Clusterpedia的YAML文件。部署数据库,安装CRD自定义资源,安装apiserver和clustersynchro,注册apiservice。
cd ./deploy/internalstorage/postgres
export STORAGE_NODE_NAME=sukai
sed "s|__NODE_NAME__|$STORAGE_NODE_NAME|g" `grep __NODE_NAME__ -rl ./templates` > clusterpedia_internalstorage_pv.yaml
kubectl create -f .
cd ../../..
kubectl apply -f ./deploy/crds
kubectl apply -f ./deploy
两个组件的deployment里可以修改镜像地址为:
m.daocloud.io/ghcr.io/clusterpedia-io/clusterpedia/clustersynchro-manager:v0.1.0
m.daocloud.io/ghcr.io/clusterpedia-io/clusterpedia/apiserver:v0.1.0
导入集群
创建Clusterpedia的CRD PediaCluster资源实例,syncResources指定Clusterpedia需要同步的资源。
apiVersion: cluster.clusterpedia.io/v1alpha2
kind: PediaCluster
metadata:
name: cluster-sukai
spec:
apiserver: "https://192.168.0.111:6443"
caData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ESXdOakE1TXpjek1Wb1hEVE15TURJd05EQTVNemN6TVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBSnUzCjlvS0MwUjVQYkgyUTZCa2ZCSzIwYzRVNkJpQmJpdW14akI5VVBZaExja2VhTkIwVHFLY2xXTjNzV2Y4QVBGM0sKYlFyb1F5UzdhNEVGWVU3WFJRcWFWTHdlSGhWZWZnMU1nZ3gzMXpsNS8wR3NqdFRlc1hyTmR4RXBvTnBvVWtrWAp1Uy8wWXZoNjZSUklPMks5WmNLKytvK1YycDl3UF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NZOWVZMG83ZitkU2Y5ZUZQY042eFRMc1gwT0J5ZW9aOFkKVkJCZ3o2eWVLR2k5Q1dmaGVlWnB2ODRMUkt4VEF3cnJaRWI2b1BzM2YwK0QrWkw1Tkh0Q0l3a0pPOHUwbXlUSApqRGZkdjN1WDRMbjFVdzdrSkpCbnB1bkZINWFUK2xJcWlFSFdxcFhqSUxyU3VoaDRoVUU4dHhJWE5mb3I0dzhCCk10OXJDUUtCZ0VLNVZrM21sK1Bsbm1wVmpHMU5wOUFtSDY1c2N0eGhYb0ZkU2VVSUZJSTZLU3plRUZnTlllc0YKajRzRnBQeFhkNk5IaS8wYlZTckJBejFveXI2cXlXK3Iwa2hyV3krb1NRakFqV3ZQdlNiWEwwNE5YcDdDci81MAp6L29OTDRXUVI0eGJyWHlUU1FhbFp4R3EvOEV0MjM0amdnbTl3UWRhTkR6anNtaEZPQ2hRCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
syncResources:
- group: apps
resources:
- deployments
- group: ""
resources:
- pods
查看集群状态,APIService,api资源包括:CRD和Aggregator两种方式注册的资源。
sukai@sukai:~$ kubectl get pediacluster
NAME APISERVER VERSION STATUS
cluster-sukai https://192.168.0.111:6443 v1.23.3 Healthy
sukai@sukai:~$ kubectl get APIService
NAME SERVICE AVAILABLE AGE
v1beta1.clusterpedia.io clusterpedia-system/clusterpedia-apiserver True 20h
sukai@sukai:~$ kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
pediaclusters cluster.clusterpedia.io/v1alpha2 false PediaCluster
collectionresources clusterpedia.io/v1beta1 false CollectionResource
resources clusterpedia.io/v1beta1 false Resources
sukai@sukai:~$
生成Kubeconfig
通过gen-clusterconfigs.sh脚本生成kubeconfig,通过server字段指定具体集群对应的API URL。
sukai@sukai:~$ cat .kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SU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Q1QUV4cTZ2ZkxrT1VKZkxaYnJMWUNGYUVIWXg1Q055TXEKUGdtdG1Tb1NlOVVKMGpEZlFvanJGakVIbWJpT0hHV0o3R2dHaStKUzhSbFZwc3pyK215c05FcitiMCtiR2hWWApNR3NDNTVCQndOTVZhSHFXZWZmRjB0ZGlSaVY4SW1xa0loSVdNSXA0RFdvbjBJc2xFYTZ0RWNrTGhaM0dsR2lrCmRvcCtGTmJZRmVZWXpPU05yRkpCZitKSnd4U1lSWGlTTXVCc29nd2NYcFZ1S0lza2hoVjU0dUEwUTcxSUNLN3IKN3VnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://master1.aiscope.io:6443/apis/clusterpedia.io/v1beta1/resources/clusters/cluster-sukai
name: cluster-sukai
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ESXdOakE1TXpjek1Wb1hEVE15TURJd05EQTVNemN6TVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBSnUzCjlvS0MwUjVQYkgyUTZCa2ZCSzIwYzRVNkJpQmJpdW14akI5VVBZaExja2VhTkIwVHFLY2xXTjNzV2Y4QVBGM0sKYlFyb1F5UzdhNEVGWVU3WFJRcWFWTHdlSGhWZWZnMU1nZ3gzMXpsNS8wR3NqdFRlc1hyTmR4RXBvTnBvVWtrWAp1Uy8wWXZoNjZSUklPMks5WmNLKytvK1YycDl3UFZLTHYvUm45WDZpRVRlVjJSeCt0RDFXbEpDRSs0UGhublJNCm1jYUJyWkxkazVONGtCb1JDMTV0alhWRkpNSVJIejNaUVhwS1RydzVEZ3pvS0MyUUpCcnl1L2kxS0pSWGNIUm8KcXd6dzExWkRMemFXU3VnQ1hMT3pCeXVvblhoOGVpWW5jbldJa0NKZzlUblczamRXU3hZTHBtZUJFaXd5TDNNegpEWUIxWTVpaVVZV0pvbERCQjNNQ0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZJK2NhY0psbW1oUElPZGJaRjV1LzMzaDVNRUtNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBQkdVanNacEZuKy9LR2VpRnpUNApKaEtITno3Yzl5NjF3eEUvNzYvcFd2eGU1RVRyT1FWbjdTQk54SUQ1OXNBKzUrcEtyNnk5TUxrUUxDZmhhZFdKCmd4WklEVmlHTmV4ejFsSlNKZ2h0L0lTOUtKbnl5YmQ1QUV4cTZ2ZkxrT1VKZkxaYnJMWUNGYUVIWXg1Q055TXEKUGdtdG1Tb1NlOVVKMGpEZlFvanJGakVIbWJpT0hHV0o3R2dHaStKUzhSbFZwc3pyK215c05FcitiMCtiR2hWWApNR3NDNTVCQndOTVZhSHFXZWZmRjB0ZGlSaVY4SW1xa0loSVdNSXA0RFdvbjBJc2xFYTZ0RWNrTGhaM0dsR2lrCmRvcCtGTmJZRmVZWXpPU05yRkpCZitKSnd4U1lSWGlTTXVCc29nd2NYcFZ1S0lza2hoVjU0dUEwUTcxSUNLN3IKN3VnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://master1.aiscope.io:6443/apis/clusterpedia.io/v1beta1/resources
name: clusterpedia
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ESXdOakE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R2dHaStKUzhSbFZwc3pyK215c05FcitiMCtiR2hWWApNR3NDNTVCQndOTVZhSHFXZWZmRjB0ZGlSaVY4SW1xa0loSVdNSXA0RFdvbjBJc2xFYTZ0RWNrTGhaM0dsR2lrCmRvcCtGTmJZRmVZWXpPU05yRkpCZitKSnd4U1lSWGlTTXVCc29nd2NYcFZ1S0lza2hoVjU0dUEwUTcxSUNLN3IKN3VnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://master1.aiscope.io:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJV2YrWkJSK1I0SFF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBeU1EWXdPVE0zTXpGYUZ3MHlNekF5TURZd09UTTNNelJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXVhOHAvUnBITmUzemhGOWkKZEFZUFlBalJIaTlBYTlGc1FhdzY4NzJoOUhBVVpneUNnU3JxUmIwc1hBOUZ4aSsybHJsSWIzUE9sRGd3bnJwZApacmI1VnQyZHRuVGhXZitJYVV4bGNraGs1VWdNQnUwa1VFVGpUTFZtY1RvczVZWGJWejk5aUEwQ3h4LzViYzcwCnJKRWRyWkJQYngrdFN1Mk5kN1paeTE5SExWYVh6a256R3NRZ1o0Z1piT09oeFVNd201OFd4a2hDeDdyczhLQnIKdmNOWXFVMC9UNXVydFJPcEJabCtYMTFnNGc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ATUS RESTARTS AGE
cluster-sukai calico-kube-controllers-6cf9c797f9-68v68 1/1 Running 24 (19h ago) 60d
cluster-sukai coredns-65c54cc984-hlhmj 1/1 Running 24 (19h ago) 60d
cluster-sukai traefik-7fc668dddc-gmwsm 1/1 Running 23 (19h ago) 60d
cluster-sukai etcd-sukai 1/1 Running 29 (19h ago) 60d
cluster-sukai kube-scheduler-sukai 1/1 Running 26 (19h ago) 60d
cluster-sukai coredns-65c54cc984-tqvps 1/1 Running 24 (19h ago) 60d
cluster-sukai kube-controller-manager-sukai 1/1 Running 26 (5h49m ago) 60d
cluster-sukai kube-proxy-qxvz2 1/1 Running 24 (19h ago) 60d
cluster-sukai calico-node-b6hkr 1/1 Running 34 (5h49m ago) 60d
cluster-sukai kube-apiserver-sukai 1/1 Running 30 (5h49m ago) 60d
sukai@sukai:~$
sukai@sukai:~$ kubectl get collectionresources workloads
CLUSTER GROUP VERSION KIND NAMESPACE NAME AGE
cluster-sukai apps v1 Deployment dex dex 60d
cluster-sukai apps v1 Deployment kube-system coredns 60d
cluster-sukai apps v1 Deployment kube-system traefik 60d
cluster-sukai apps v1 Deployment metallb-system controller 60d
cluster-sukai apps v1 Deployment clusterpedia-system clusterpedia-clustersynchro-manager 20h
cluster-sukai apps v1 Deployment ldap openldap 60d
cluster-sukai apps v1 Deployment clusterpedia-system clusterpedia-apiserver 20h
cluster-sukai apps v1 Deployment clusterpedia-system clusterpedia-internalstorage-postgres 21h
cluster-sukai apps v1 Deployment kube-system calico-kube-controllers 60d
sukai@sukai:~$
sukai@sukai:~$ kubectl --cluster clusterpedia get -n kube-system deployments -l "search.clusterpedia.io/clusters in (cluster-sukai)"
CLUSTER NAME READY UP-TO-DATE AVAILABLE AGE
cluster-sukai calico-kube-controllers 1/1 1 1 60d
cluster-sukai coredns 2/2 2 2 60d
cluster-sukai traefik 1/1 1 1 60d
sukai@sukai:~$
sukai@sukai:~$ kubectl get --raw="/apis/clusterpedia.io/v1beta1/resources/api/v1/namespaces/kube-system/pods" | jq
{
"kind": "PodList",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"metadata": {
"name": "calico-kube-controllers-6cf9c797f9-68v68",
"generateName": "calico-kube-controllers-6cf9c797f9-",
"namespace": "kube-system",
"uid": "779d84e4-a333-4e13-9aab-975fbc45809c",
"resourceVersion": "241919",
"creationTimestamp": "2022-02-06T09:43:03Z",
"labels": {
"k8s-app": "calico-kube-controllers",
"pod-template-hash": "6cf9c797f9"
},
"annotations": {
"cni.projectcalico.org/podIP": "10.11.77.100/32",
"cni.projectcalico.org/podIPs": "10.11.77.100/32",
"shadow.clusterpedia.io/cluster-name": "cluster-sukai"
},
"ownerReferences": [
{
"apiVersion": "apps/v1",
"kind": "ReplicaSet",
"name": "calico-kube-controllers-6cf9c797f9",
"uid": "2e8cea26-7b8c-4369-879f-83699e83452f",
"controller": true,
"blockOwnerDeletion": true
}
]
},
"spec": {
"volumes": [
{
"name": "kube-api-access-bdl98",
"projected": {
"sources": [
{
"serviceAccountToken": {
"expirationSeconds": 3607,
"path": "token"
}
},
{
"configMap": {
"name": "kube-root-ca.crt",
"items": [
{
"key": "ca.crt",
"path": "ca.crt"
}
]
}
},
{
"downwardAPI": {
"items": [
{
"path": "namespace",
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}
]
}
}
],
"defaultMode": 420
}
}
],
"containers": [
{
"name": "calico-kube-controllers",
"image": "docker.io/calico/kube-controllers:v3.18.1",
"env": [
{
"name": "ENABLED_CONTROLLERS",
"value": "node"
},
{
"name": "DATASTORE_TYPE",
"value": "kubernetes"
}
],
"resources": {},
"volumeMounts": [
{
"name": "kube-api-access-bdl98",
"readOnly": true,
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
}
],
"readinessProbe": {
"exec": {
"command": [
"/usr/bin/check-status",
"-r"
]
},
"timeoutSeconds": 1,
"periodSeconds": 10,
"successThreshold": 1,
"failureThreshold": 3
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"nodeSelector": {
"kubernetes.io/os": "linux"
},
"serviceAccountName": "calico-kube-controllers",
"serviceAccount": "calico-kube-controllers",
"nodeName": "sukai",
"securityContext": {},
"schedulerName": "default-scheduler",
"tolerations": [
{
"key": "CriticalAddonsOnly",
"operator": "Exists"
},
{
"key": "node-role.kubernetes.io/master",
"effect": "NoSchedule"
},
{
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
},
{
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
}
],
"priorityClassName": "system-cluster-critical",
"priority": 2000000000,
"enableServiceLinks": true,
"preemptionPolicy": "PreemptLowerPriority"
},
"status": {
"phase": "Running",
"conditions": [
{
"type": "Initialized",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2022-02-06T09:43:34Z"
},
{
"type": "Ready",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2022-04-08T03:11:16Z"
},
{
"type": "ContainersReady",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2022-04-08T03:11:16Z"
},
{
"type": "PodScheduled",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2022-02-06T09:43:34Z"
}
],
"hostIP": "192.168.0.111",
"podIP": "10.11.77.100",
"podIPs": [
{
"ip": "10.11.77.100"
}
],
"startTime": "2022-02-06T09:43:34Z",
"containerStatuses": [
{
"name": "calico-kube-controllers",
"state": {
"running": {
"startedAt": "2022-04-08T03:11:12Z"
}
},
"lastState": {
"terminated": {
"exitCode": 2,
"reason": "Error",
"startedAt": "2022-04-07T11:58:47Z",
"finishedAt": "2022-04-07T13:51:23Z",
"containerID": "docker://1045b5d0972421d9b33fffb3463726d5db83e6b0edc948a2628c50fd4800b75c"
}
},
"ready": true,
"restartCount": 24,
"image": "calico/kube-controllers:v3.18.1",
"imageID": "docker-pullable://calico/kube-controllers@sha256:bd19b85801762a1634e6b5c569e7c8fd528be352b31777ae047b99ed98b7da7f",
"containerID": "docker://57cadf55623fb407464f63798f83c2a72858e9d9a6e34120cb565631e39c4666",
"started": true
}
],
"qosClass": "BestEffort"
}
},
总结
Clusterpedia提供的用户请求API为/apis/clusterpedia.io/v1beta1/resources/clusters/{cluster-sukai}或/apis/clusterpedia.io/v1beta1/resources两种,指定集群和所有集群。资源请求处理后,将cluster信息保存到context中,API为/apis/clusterpedia.io/v1beta1/resources/api和/apis/clusterpedia.io/v1beta1/resources/apis。通过Aggregator方式由genericServer注册API资源,Group/Version为clusterpedia.io/v1beta1,Resource为collectionresources,resources。genericServer将资源resources的路径/api和/apis委托给kubeResourceAPIServer提供服务。