騰訊云部署Eclipse Che(云原生IDE)

準(zhǔn)備工作

  • 已經(jīng)創(chuàng)建了一個(gè)騰訊云容器服務(wù)集群
  • 配置好kubectl客戶端
  • 已經(jīng)有一個(gè)騰訊云(DNSPod)解析的域名

安裝chectl

$ bash <(curl -sL  https://www.eclipse.org/che/chectl/)

安裝NGINX Ingress Controller

詳細(xì)安裝過程見:https://kubernetes.github.io/ingress-nginx/deploy/

這里需要注意的是是controller使用的鏡像地址國內(nèi)無法訪問,需要換成你自己的鏡像地址,可以將鏡像翻墻下載,然后上傳到騰訊云容器服務(wù)的鏡像倉庫里。

安裝cert-manager

cert-manager是原生的Kubernetes證書管理控制器。 它可以幫助從各種證書機(jī)構(gòu)頒發(fā)證書,例如Let's Encrypt,HashiCorp Vault,Venafi,簡單的簽名密鑰對(duì)或生成自簽名證書。

它將確保證書有效并且是最新的,并在到期前嘗試在配置的時(shí)間續(xù)訂證書。

# Kubernetes 1.16+
$ kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.2/cert-manager.yaml

# Kubernetes <1.16
$ kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.2/cert-manager-legacy.yaml

本文只要確保會(huì)使用即可,有時(shí)間再詳細(xì)介紹一下cert-manager

安裝dnspod webhook

申請(qǐng)dnspod的api調(diào)用憑證

在安裝dnspod webhook之前,需要新申請(qǐng)dnspod調(diào)用api接口的id和和token,首先登陸dnspod管理控制臺(tái)(使用騰訊云賬號(hào)即可登陸),如下圖所示:

dnspodconsole.jpg

進(jìn)入“密鑰管理”頁面,點(diǎn)擊“創(chuàng)建密鑰”。

keymanager.jpg

在創(chuàng)建“創(chuàng)建密鑰”頁面,輸入密鑰名稱,點(diǎn)擊“確定”即可。

createkey.jpg

創(chuàng)建成功后,如下圖所示:

createkeysuccess.jpg

復(fù)制保存ID和Token、復(fù)制保存ID和Token、復(fù)制保存ID和Token,后面將用到。

安裝dnspod webhook

下載代碼:

$ git clone https://github.com/qqshfox/cert-manager-webhook-dnspod.git

使用helm安裝:

$ cd cert-manager-webhook-dnspod
$ helm install --name cert-manager-webhook-dnspod ./deploy/cert-manager-webhook-dnspod \
    --namespace <NAMESPACE-WHICH-CERT-MANAGER-INSTALLED> \
    --set groupName=<GROUP_NAME> \
    --set secrets.apiID=<DNSPOD_API_ID>,secrets.apiToken=<DNSPOD_API_TOKEN> \
    --set clusterIssuer.enabled=true,clusterIssuer.email=<EMAIL_ADDRESS>

注意:上面的命令中中,namespace配置為che,GROUP_NAME建議使用acme.xxx.com這樣的唯一標(biāo)識(shí)即可,DNSPOD_API_ID和DNSPOD_API_TOKEN為上一步申請(qǐng)的api調(diào)用憑證,EMAIL_ADDRESS配置為您常用地址即可,在證書過期的時(shí)候會(huì)發(fā)送提醒之類到這個(gè)郵箱地址。

安裝完后,webhook將自動(dòng)幫您創(chuàng)建一個(gè)cluster issuer,如下所示:

[root@VM_0_10_centos cheworkspace]# kubectl get clusterissuer
NAME                                         READY   AGE
cert-manager-webhook-dnspod-cluster-issuer   True    14h

查看yaml格式,如下:

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  ……
  name: cert-manager-webhook-dnspod-cluster-issuer
  ……
spec:
  acme:
    email: zhcj11118@126.com
    preferredChain: ""
    privateKeySecretRef:
      name: cert-manager-webhook-dnspod-letsencrypt
    server: https://acme-v02.api.letsencrypt.org/directory
    solvers:
    - dns01:
        webhook:
          config:
            apiID: 184422
            apiTokenSecretRef:
              key: api-token
              name: cert-manager-webhook-dnspod-secret
          groupName: acme.venusource.com
          solverName: dnspod

申請(qǐng)ssl證書

eclipse che要求使用一個(gè)泛域名來自動(dòng)配置相關(guān)的服務(wù)及實(shí)現(xiàn)多租戶模式,我們需要解析一個(gè)*.xxx.xxx.cn這樣的域名到nginx controller,所以cert-manager申請(qǐng)證書時(shí),必須使用dns01方式認(rèn)證域名所有權(quán),HTTP方式不支持泛域名的所有權(quán)認(rèn)證。請(qǐng)確保您在騰訊云申請(qǐng)了相關(guān)了域名。

新建文件che-certificate.yaml,內(nèi)容如下:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: che-certificate
  namespace: che
spec:
  dnsNames:
    - 'ide.gwunion.cn'
    - '*.ide.gwunion.cn'
  secretName: che-tls
  issuerRef:
    name: cert-manager-webhook-dnspod-cluster-issuer
    kind: ClusterIssuer

系統(tǒng)將調(diào)用letsencrypt的acme的接口為我們的域名申請(qǐng)證書。

注意:這里的secretName必須為che-tls,chectl在安裝時(shí)會(huì)檢查,如果有有che-tls這個(gè)secret就不在自動(dòng)創(chuàng)建一個(gè)自簽名的證書,直接使用che-tls。

執(zhí)行下面的命令查看證書申請(qǐng)情況

kubectl describe Certificate che-certificate -n che

等待通過dns方式對(duì)域名進(jìn)行所有權(quán)認(rèn)證,一段1-2分鐘內(nèi)證書就申請(qǐng)完畢,并保存到名稱為che-tls的secret內(nèi)。

安裝eclipse che

安裝之前,請(qǐng)確保您使用的域名*.xxx.xxx.com已經(jīng)解析到ingress nginx controller的IP地址,查看IP地址可執(zhí)行下面的命令查看:

kubectl get services --namespace ingress-nginx

IP地址為EXTERNAL-IP字段,請(qǐng)?jiān)隍v訊云域名解析控制臺(tái)或dnspod域名解析控制臺(tái)解析*.xxx.xxx.com的A記錄到EXTERNAL-IP。

$ chectl server:start -a helm -b ide.gwunion.cn -p k8s --multiuser --k8spodreadytimeout=13000000 --k8spodwaittimeout=30000000
? Current Kubernetes context: 'cls-8437x8wt-context-default'
  ? Verify Kubernetes API...OK
  ? ??  Looking for an already existing Eclipse Che instance
    ? Verify if Eclipse Che is deployed into namespace "che"...it is not
  ? ??  Kubernetes preflight checklist
    ? Verify if kubectl is installed
    ? Verify remote kubernetes status...done.
    ? Check Kubernetes version: Found v1.18.4-tke.2.
    ? Verify domain is set...set to ide.gwunion.cn.
    ↓ Check if cluster accessible [skipped]
  ? Start following logs
    ↓ Start following Operator logs [skipped]
    ? Start following Eclipse Che logs...done
    ? Start following Postgres logs...done
    ? Start following Keycloak logs...done
    ? Start following Plugin registry logs...done
    ? Start following Devfile registry logs...done
  ? Start following events
    ? Start following namespace events...done
 ?   Warning: Consider using the more reliable 'OLM' installer when deploying a stable release of Eclipse Che (--installer=olm).
  ? ???  Running Helm to install Eclipse Che
    ? Verify if helm is installed
    ? Check Helm Version: Found v3.3.1+g249e521
    ? Create Namespace (che)...does already exist.
    ? Check Eclipse Che TLS certificate...TLS certificate secret found
    ? Check Cluster Role Binding...done.
    ? Preparing Eclipse Che Helm Chart...done.
    ? Updating Helm Chart dependencies...done.
    ? Deploying Eclipse Che Helm Chart...done.
  ? ?  Post installation checklist
    ? PostgreSQL pod bootstrap
      ? scheduling...done.
      ? downloading images...done.
      ? starting...done.
    ? Devfile registry pod bootstrap
      ? scheduling...done.
      ? downloading images...done.
      ? starting...done.
    ? Plugin registry pod bootstrap
      ? scheduling...done.
      ? downloading images...done.
      ? starting...done.
    ? Eclipse Che pod bootstrap
      ? scheduling...done.
      ? downloading images...done.
      ? starting...done.
    ? Retrieving Eclipse Che server URL... https://che-che.ide.gwunion.cn
    ? Eclipse Che status check
  ? Show important messages
    ? Autogenerated Keycloak credentials are: "admin:iZ245VK5RUHV"
Command server:start has completed successfully.

這里簡單說明一下chectl幾個(gè)參數(shù):

  • -a helm 為安裝方式使用helm chart
  • -b ide.gwunion.cn 為eclipse che使用的訪問域名
  • -p k8s 安裝平臺(tái)為獨(dú)立安裝的k8s平臺(tái)
  • --multiuser 支持多用戶
  • --k8spodreadytimeout=13000000 等待pod為ready狀態(tài)的超時(shí)時(shí)長
  • --k8spodwaittimeout=30000000 等待pod啟動(dòng)的超時(shí)時(shí)長,為什么要配置那么長時(shí)間,主要是由于國內(nèi)網(wǎng)絡(luò)狀態(tài)太差,拉取鏡像的時(shí)間較長,所以越大越好。

安裝完成后,即可通過 https://che-che.xxx.com訪問您的eclipse che云開發(fā)ide環(huán)境了,如下圖所示:

chelogin.jpg

首次需要注冊用戶,然后登陸控制臺(tái)即可,讓您的團(tuán)隊(duì)盡情的享用云原生IDE吧。

chedashboard.jpg
cheide.jpg

以后不用給你的團(tuán)隊(duì)配筆記本電腦了,人手一個(gè)ipad,性能可按需配置,就像下面這樣:

ipadworkstation.jpg

后續(xù)的優(yōu)化提升

由于目前平臺(tái)所有鏡像都使用國外的鏡像,下載速度較慢,建議在生產(chǎn)環(huán)境使用將鏡像本地化,可以使用騰訊云的容器鏡像服務(wù)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容