1分钟k8s部署好pycharm和Goland网页版开发编译器

2021年4月15日 244点热度 0人点赞 0条评论

想必大家都知道,在本地电脑安装开发使用编译器很占内存和CPU空间,并且很耗电,时间长了,电脑烫手,除非使用的是苹果M1,

近期JetBrains公司,推出一款云端版本的编译器,想必大家都猜到了,话不多说,分享下如何把golang编译器和python编译器部署到云服务器上,

这样随时随地都能撸代码了,是不是美滋滋。


1.部署前准备好镜像: 

registry.jetbrains.team/p/prj/containers/projector-pycharm-p               latest                3a29aba727d2        3 weeks ago         1.81GBregistry.jetbrains.team/p/prj/containers/projector-goland

2.准备好存储"pv":

[root@dockercore ]# cat pv0.yaml---apiVersion: v1kind: PersistentVolumemetadata:  name: project-dataspec:  capacity:    storage: 10Gi  accessModes:  - ReadWriteMany  persistentVolumeReclaimPolicy: Recycle  nfs:    server: 192.168.15.227    path:  /data/goang/dockercore

注意细节:/data/goang/dockercore 这个目录必须具有读写权限!

wget  https://studygolang.com/dl/golang/go1.16.3.linux-amd64.tar.gz 

把上面go1.16.3.linux-amd64.tar.gz  解压到/data/goang/dockercore目下.

3.在准备deployment以及Service

[root@dockercore ]# cat goland.yamlkind: PersistentVolumeClaimapiVersion: v1metadata:  name: project-dataspec:  accessModes:    - ReadWriteMany  resources:    requests:      storage: 10Gi---apiVersion: apps/v1kind: Deploymentmetadata:  name: goland  labels:    app: golandspec:  replicas: 1  selector:    matchLabels:      app: goland  template:    metadata:      labels:        app: goland    spec:      containers:      - name: goland        image: registry.jetbrains.team/p/prj/containers/projector-goland        imagePullPolicy: IfNotPresent        volumeMounts:        - mountPath: /etc/localtime          name: localtime        - mountPath: /home/projector-user          name: project-data      imagePullSecrets:      - name: regcred      volumes:      - name: localtime        hostPath:          path: /etc/localtime      - name: project-data        persistentVolumeClaim:          claimName: project-data---apiVersion: v1kind: Servicemetadata:  name: goland  labels:    app: golandspec:  selector:    app: goland  ports:    - protocol: TCP      name: http      port: 80      targetPort: 8887

4.在准备ingress以及域名配置如下:

[root@dockercore ]# cat  https-ingress.yaml---apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: goland-ingress  annotations:    kubernetes.io/ingress.class: "nginx"    nginx.ingress.kubernetes.io/configuration-snippet: keepalive_timeout  0;    nginx.ingress.kubernetes.io/proxy-body-size: "2000m"    nginx.org/client-max-body-size: "4096m"      nginx.ingress.kubernetes.io/cors-allow-credentials: "true"    nginx.ingress.kubernetes.io/enable-cors: "true"    nginx.ingress.kubernetes.io/service-weight: ""    nginx.ingress.kubernetes.io/auth-type: basic    nginx.ingress.kubernetes.io/auth-secret: basic-auth    nginx.ingress.kubecnetes.io/auth-realm: 'Authentication Required - xiaotie'    nginx.ingress.kubernetes.io/ssl-redirect: "false"    nginx.ingress.kubernetes.io/enable-cors: "true"    nginx.ingress.kubernetes.io/enable-modsecurity: "true"    nginx.ingress.kubernetes.io/enable-owasp-core-rules: "true"    nginx.ingress.kubernetes.io/server-snippet: keepalive_timeout  0;    nginx.ingress.kubernetes.io/ssl-redirect: "false"    nginx.ingress.kubernetes.io/server-snippet: client_header_buffer_size 2046k;    nginx.ingress.kubernetes.io/proxy-send-timeout: "9000"    nginx.ingress.kubernetes.io/proxy-read-timeout: "9000"    nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
spec: tls: - hosts: - nginx secretName: go-tls rules: - host: go.xxoo.com http: paths: - path: / pathType: Prefix backend:          serviceName: goland servicePort: 80

注意   把go.xxoo.com 替换成自己的域名!

           把go-tls 替换成自己域名的证书,或者不要证书也行

开始部署:

 kubectl  apply -f  pv0.yaml 
kubectl  apply -f goland.yaml
kubectl apply -f https-ingress.yaml

图片

查看日志:

图片

从浏览器访问:   go.xxoo.com

图片

按照好之后激活后开始汉化:

图片

安装汉化插件:

图片

开始运行第一程序测试:

图片

到此就完成了,当然,为了python的编译器环境只需把镜像替换成projector-pycharm-p 启动服务也是一样的效果。


安全配置:

在 ingress 配置下注意,在访问你的域名时候进行用户和密码验证登陆。

    nginx.ingress.kubernetes.io/auth-type: basic    nginx.ingress.kubernetes.io/auth-secret: basic-auth    nginx.ingress.kubecnetes.io/auth-realm: 'Authentication Required - xiaotie'

效果如下:

图片

                  关注我让你成为云端最靓的builder

图片

59701分钟k8s部署好pycharm和Goland网页版开发编译器

root

这个人很懒,什么都没留下

文章评论