AWS-EKS上安装KubeSphere
AWS-EKS上安装KubeSphere
1.准备工作
1.1 查看StorageClass是否有默认标记
1.1.1 设置默认 StorageClass
1.1.2 创建一个新的StorageClass
2.安装KubeSphere
2.1 最小化安装KubeSphere
2.2 访问KubeSphere控制台
1.准备工作
1.1 查看StorageClass是否有默认标记
#查看StorageClass是否有默认标记
kubectl get storageclass
注意查看标记为(default)的StorageClass
如果没有看到(default),则意味着目前没有被标记为默认的StorageClass
1.1.1 设置默认 StorageClass
#如果没有设置默认的 StorageClass,可以通过以下步骤来指定一个默认的StorageClass
#选择一个合适的 StorageClass,然后将其标记为默认
假设gp2是你想要设置为默认的StorageClass,你可以运行以下命令:
kubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
#再次查看
kubectl get storageclass
#你应该会看到类似如下的输出,表明 gp2 已被标记为默认
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
standard kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 10d
gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer true 10d
1.1.2 创建一个新的StorageClass
#如果你当前没有任何 StorageClass,你可以通过以下步骤创建一个新的 StorageClass 并设置为默认
#创建storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: gp2
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
#创建StorageClass
kubectl apply -f storageclass.yaml
2.安装KubeSphere
#官方文档
https://kubesphere.io/zh/docs/v3.4/installing-on-kubernetes/hosted-kubernetes/install-kubesphere-on-eks/
2.1 最小化安装KubeSphere
#使用kubectl安装 KubeSphere,以下命令仅用于默认的最小安装
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/cluster-configuration.yaml
#检查安装日志
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
#安装完成后,会看到以下消息
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Account: admin
Password: P@88w0rd
NOTES:
1. After logging into the console, please check the
monitoring status of service components in
the "Cluster Management". If any service is not
ready, please wait patiently until all components
are ready.
2. Please modify the default password after login.
#####################################################
https://kubesphere.io 2020-xx-xx xx:xx:xx
2.2 访问KubeSphere控制台
#查看 ks-console 服务
kubectl get svc -n kubesphere-system
执行`kubectl edit ks-console`将 service 类型`NodePort` 更改为`LoadBalancer`完成后保存文件
#修改Service服务ks-console
kubectl edit svc ks-console -n kubesphere-system
#带注释的地方是需要修改添加的
#KubeSphere服务是内部组件所以使用内网暴露方式
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: ks-core
meta.helm.sh/release-namespace: kubesphere-system
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true" #启用跨可用区负载均衡
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip #将流量直接转发到 Pod IP
service.beta.kubernetes.io/aws-load-balancer-scheme: internal #负载均衡内网公开
service.beta.kubernetes.io/aws-load-balancer-type: external #负载均衡 NLB
creationTimestamp: "2024-07-26T08:25:25Z"
...
- name: nginx
nodePort: 30880
port: 80
protocol: TCP
targetPort: 8000
selector:
app: ks-console
tier: frontend
sessionAffinity: None
type: LoadBalancer #这里原本的NodePort修改成LoadBalancer
#获取的EXTERNAL-IP
kubectl get svc -n kubesphere-system
NAME TYPE CLUSTER-IP EXTERNAL-IP
ks-apiserver ClusterIP 10.100.108.212 <none>
ks-console LoadBalancer 10.100.160.240 ad107c54ee456744c91c8da0b9321f2c-1235661477.ap-east-1.elb.amazonaws.com
ks-controller-manager ClusterIP 10.100.126.96 <none>
使用 EKS 生成的 external-ip 访问 KubeSphere 的 Web 控制台
使用默认帐户和密码(`admin/P@88w0rd`)登录控制台
评论区