在 Amazon Elastic Kubernetes Service 中创建缓存客户端部署
您需要在 Amazon Elastic Kubernetes Service 集群内部署客户端资源以设置功能性客户端环境。
为 Amazon Elastic Kubernetes Service 创建客户端密钥
由于您的客户端应用程序托管在 dockerhub 上的私有存储库上,因此您需要创建一个包含客户端登录凭据的文件。获得此文件后,您可以轻松在 Amazon Elastic Kubernetes Service 集群中部署客户端应用程序,而无需每次都提供用户 ID 和密码。我们称这个文件为 客户端秘密.yaml 其内容如下所示:
kind: Secret
apiVersion: v1
metadata:
name: ncache-private
namespace: ncache
data:
.dockerconfigjson: >-
...
type: kubernetes.io/dockerconfigjson
执行以下命令以在 Kubernetes 环境中运行此配置。
kubectl create -f [dir]/clientsecrets.yaml
创建 NCache 客户资源
现在,让我们开始创建您的客户端资源文件,其中包含在 EKS 集群中部署和运行客户端应用程序所需的信息。 下面显示的是这个 YAML 文件的内容。
备注
创建准备好部署的 YAML 文件所需的参数在 查看房源 表。
kind: Deployment
apiVersion: apps/v1beta1 # it depends on the underlying Kubernetes version
metadata:
name: client
spec:
replicas: 1
template:
metadata:
labels:
app: client
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
containers:
- name: client
image: # Your docker client image here
ports:
- name: app-port
containerPort: 80
# In case of NCache client installation, add the following remaining ports
- name: management-tcp
containerPort: 8250
- name: management-http
containerPort: 8251
- name: client-port
containerPort: 9800
要将此文件部署为 Kubernetes 集群中的 pod 并使其启动并运行,请在 AWS 命令行界面中执行以下命令:
kubectl create -f [dir]/client.yaml
接下来的步骤是将 创建 NCache 簇 在 Amazon Elastic Kubernetes Service 集群中,这将在下一章中进行解释。
参见
创建访问权限 NCache EKS 中的管理
创建 NCache EKS 中的客户端
在 EKS 中创建缓存集群
显示器 Ncache EKS 中的集群和客户端