IntelliJ IDEA - Kubernetes


IntelliJ IDEA 目录


IntelliJ IDEA - Kubernetes

  • 一、IntelliJ IDEA - Kubernetes
    • 1. Kubernetes 简介
    • 2. IDEA 连接 Kubernetes
      • 2.1 复制 Kubernetes 集群 conf 文件
    • 2.2 配置 IDEA Kubernetes 相关配置项
    • 2.3 使用 IDEA Kubernetes 相关功能
    • 3. 常用技巧


一、IntelliJ IDEA - Kubernetes


1. Kubernetes 简介

请参考 -> Kubernetes 相关章节

2. IDEA 连接 Kubernetes

2.1 复制 Kubernetes 集群 conf 文件

在项目根目录下创建好目录结构(建议结构:/deploy/kubernetes),将 Kubernetes 集群 conf 文件(默认位置:master 节点 /root/.kube/conf)复制到该目录下。

conf 样例(此内容有需要自行调整部分):

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ESXlNREV3TURReE4xb1hEVE15TURJeE9ERXdNRFF4TjFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDhzCnFCelhEM1FtZUxYRTNtRFovUm5RUFJyZDVsQS83akxsT0NTYzhNRTlyRmRHNE83M3FaS29rcGJ3ZVhlcHQwNzgKN0hkdGR0Q2RoaER4MDgzVm82ZTNTbVZIeU9MYVRBZGNxTEtNSXpLQTQ3VkQ4cGh4WW1wZEt0UVgyREFTVm9UZApGRGFRbGpOcjJGSXdId2Z5RlJzR0tCQmdRUm9mdlE3czNzN1o4YnNLTURpN0Q0QmNvNFh6RmQzSG9VQnlQa0l6CjlQYnVXTjBXTGgwRnhXaDBBL0dKRXgwRnVkVm9Jc1ROV0ZtZjJQcnRkamNqYlRMOEgzNlpDb01nZnphMElFZXgKUjcydnpRTFVST2ZVelZkZlRsMHF4M1pPbkVyK1lFaVczTjhZWlgvRmJ5eWVJM3hTbGpyNEZLeUxWTUpNUWVjbApQaGZpdzlVaWxESkNBRnVIU0JNQ0F3RUFBYU5DTUVBd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZNYktQQWlsMGVPUUt1cEVKd0ZRcENma01hN3JNQTBHQ1NxR1NJYjMKRFFFQkN3VUFBNElCQVFDbm5ZV0xXSldXeGQ4RjlUUWkyMGg2RmR3RFJtbXY3QlBicnVoY1FDU3ErVVRmRjBlYQpHNDJtSjVja0VZSEk3eGdiRytLRlFiZ2RFdjVhb0o0bUpkWXFlY2ErdVNqaEtuWTFzaXFId0JjbFpOMVhWOGdYCkNtYjlFZFJYM3NXM2dLdjkzVzFXOS9xTnBFSkZqQitQaGNPRW8yampyRSs4TUVML3h0dUlSVTRZMnlVYUltQXcKa1NTRk5JMWhrc2pRMUtjTzk4Q3FvV0liNFNtcHY4L0hPdlYra2hJV0VpenUwWUJVMzlIRXhJYy8rQ2tic3B5RwozTjErY1NLUXZMTEI4cHNnb0NtMVhJNWQvN2xMVTNYR0NWb3pPSDc2dVJ2RGZpM2wvRlp5a29VcGFOWjhMaHFKClh2Yk1pNmpEcTBML0QvdW5oTDlRY0RxU1BtblpiLzdEY054RwotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
    server: https://192.168.80.200:16443 # 一般为域名形式(https://master.k8s.io:16443),请自行修改为 master 节点对应的 IP。
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: k8s-admin@80200
current-context: k8s-admin@80200
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURFekNDQWZ1Z0F3SUJBZ0lJWFVzWWRuZlQ0bE13RF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dRQ0hBdG5CbVMxMFNvNk9ERGdpcnd5NnNIQzNVWG02RE5pTEViaW8KTXlyVDhReld5dlRkd2pubVhtZGdwZFE5WmkyL0JmTE9pTVI5Q3Y3N2h1dEFieG1KVFZtM25hNnlRTDRxb3NtawpMSy9EQmVTZ09vdWdvN1IrQWMxczJXcld2MURSL2QyL3RlbVVreFlmYlpoSy9hdXVrU0JMYTh1cU15MlhJeXVnClNtZ2RrUUtCZ0ZiZDhkaGN1SVU5WWJxbUxUTjhlbk0yWVlYbWxsVXFlOUlRL3ppcjc0OGZ5SWdZSnJzNnBCV1gKSUgzSFF6T0FMQ0YrdHZ2WUlNZWZTUVRKR0c5b1h0SVNONWsyVjA0MkJqLy9BRFdvSUZWdlVxcnZPUDJIWWllZwo2Ulp5cTdMbkhCekJyZElERHAvT2VFNXgrV01JWlUzb3lOQzZKY05ieGxoUnBHR1Y3RGpICi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==

2.2 配置 IDEA Kubernetes 相关配置项

  1. 打开设置;
  2. 选择 【语言和框架】 -> 【Kubernetes】;
  3. 调整 【Kubernetes API 版本:】 为自己集群的版本;
  4. 勾选 【使用活动集群中的 API 架构(如果可用)】;
  5. 点击 “+” 并选择 【添加文件】;
  6. 选中 Kubernetes conf 文件;
  7. 选择 【构建、执行、部署】 -> 【Kubernetes】;
  8. 为 【kubeconf 文件路径:】 选中 Kubernetes conf 文件;
  9. 点击 【检查配置】,提示:“成功检查”即可;
  10. 【应用】 -> 【确定】;

2.3 使用 IDEA Kubernetes 相关功能

  1. 打开底部”工具栏“ 【服务】;
    效果图:
    IntelliJ IDEA - Kubernetes_第1张图片

3. 常用技巧

你可能感兴趣的:(IntelliJ,IDEA,Kubernetes)