K8s小白?应用部署太难?看这篇就够了!

在云原生趋势下,容器和 Kubernetes 可谓是家喻户晓,许多企业内部的研发团队都在使用 Kubernetes 打造 DevOps 平台。从最早的容器概念到 Kubernetes 再到 DevOps/GitOps 整个技术链非常庞大,Kubernetes 的优势也显而易见 可移动 可扩展 自修复 等,但有一个劣势点就是技术门槛太高,对于开发者来说单单一个 Kubernetes 就够我们学习一段时间了。

通常我们在 Kubernetes 中部署应用需要用 Dockerfile 将业务打成镜像,然后编写 Kubernetes 的 Yaml 部署应用,再结合 Jenkins 的 Pipeline 实现 CI/CD。对于不懂容器的开发者来说,要学习 Dockerfile 语法、K8s Yaml 语法、 Jenkins Pipeline 语法,学习成本有点高。”我还要 Coding 呢!”

本文将分别介绍 如何在 Kubernetes 中部署应用 和 如何在 Rainbond 中部署应用。

在 Kubernetes 中部署应用

在 Kubernetes 中部署一个 Nginx 并通过 NodePort 访问和通过 Ingress 访问。

  1. 创建 nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
  1. 创建 nginx-service.yaml,并设置 Service 类型为 NodePort
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30080
  1. 创建 Nginx Deployment 和 Nginx Service
$ kubectl apply -f nginx-deployment.yaml
$ kubectl apply -f nginx-service.yaml
  1. 创建 Ingress 策略
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-service
            port:
              number: 80
kubectl apply -f nginx-ingress.yaml

以上就是在 Kubernetes 中部署一个 Nginx 并开启 Nodeport 访问和 Ingress 访问的简单示例,这个过程需要理解 K8s 的资源类型 Deployment Service Ingress,以及资源类型之间如何绑定的等等。这仅仅是冰山一角,对于复杂的业务需要写多个这样的 Yaml 以及理清楚业务之间的依赖关系等。

在 Rainbond 中部署应用

Rainbond 是建立在 Kubernetes 之上的云原生应用管理平台,遵循以应用为中心的概念,其目的就是为了让用户不在编写复杂的 Yaml 文件就能轻松的将自己的业务部署在 Kubernetes 中。

通过一条命令安装 Rainbond Allinone

这里同样也是部署一个 Nginx 并通过 NodePort 访问和通过 Ingress 访问。

  1. 部署 Nginx 应用,在 Rainbond 团队视图内 -> 选择基于镜像创建组件 -> 镜像地址选择 nginx:latest 创建即可。
  1. 开启 Ingress 访问,在 Nginx 组件内 -> 端口 -> 打开对外服务,默认会生成可访问的域名。
  1. 开启 Nodeport 访问,在 应用视图内 -> 网关 -> TCP/UDP -> 添加策略一键绑定 TCP 访问策略。

这里有几个 Rainbond 的概念:

「组件:」 组件对应 K8s 中的控制器,比如 Deployment、Statefulset 等。

「应用:」 应用是由多个组件组成的应用,通过一套微服务包含多个组件称之为一个应用。

「网关:」 网关是 Rainbond 对外访问的入口,域名、Tcp访问都是通过网关生成的访问策略。

还有文中没提到的一些概念,比如:

「团队:」 Rainbond的团队意义上是分配给部门使用的,比如开发部门、测试部门,实际底层上团队对应的是 K8s NameSpace。

最后

在 Kubernetes 中部署应用需要我们大量学习容器、Kubernetes的概念以及 Yaml 语法等等。而在 Rainbond 上部署应用只需要在 UI 界面上点点即可完成部署,这对不懂 K8s 和容器的同学们很友好,可以快速部署自己的业务。

K8S中文社区微信公众号

评论 6

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #4

    Hello Guys, I just completed my divorce with my cheating husband of 10 years with two beautiful kids when i got a solid evidence of his unfaithfulness on extra marital affairs and his infidelity lifestyle, And the various applications he used to hide chats and lot of secret on his cell phone. Then, i decided to hire (Henry clark) an hacker and a PI just to be 100% sure because i don’t want to confront him or take any kinda step without proof, fact and figures because that could leads to defamation… It was with this great, honest, professional and trustworthy Man i got to know my husband is a professional cheater and has been using this app to hide most of his chats. This great hacker helped me broke to into his cell phone activities and wired everything he does on his cell phone directly to my phone and i was able to monitor and track him directly from my phone remotely without him knowing,
    Contact the Ethical hacker via email, Henryclarkethicalhacker@gmail.com you can also reach him on Whatsapp 18134211326..

    Steve Jenna4个月前 (09-19)回复
    • Finding your partner cheating isn’t easy. People who cheat are generally smart enough to hide it. Therefore, their partners often spend nights awake wondering if their suspicions are true or not. Luckily today you are going to read about a way through which you can know for sure if your partner is cheating on you. This happens by sending a mail to Jeffreyethicalhacker Don’t worry, you aren’t going to need your partner’s phone in order to see what your partner had been up to. The way I told you worked for me, and it was remotely.
      contact him via email; Jeffreyethicalhacker@gmail.com
      whatsapp or Text on : +1 (747)345-9036

      dda liey5542个月前 (12-04)回复
    • I dont like to meddle into people’s relationship but at thesame time its not appropriate the way men cheat this days and even maltreated their wives whenever confronted,it really baffle me.l was in this situation some month ago l have to search some forum then l came accross this hacker via his mail: samsmithcyberhost@gmail,com this guy really unveil somethings l can’t imagine happening in my relationship.l think it’s high time we ladies have to hire someone like sam in other to get the truth about your spouse it really help. contact him via
      Email: Samsmithcyberhost@gmail.com
      Text or Whatsapp on: +1 (747)345-9036..
      u9io

      dda liey5542个月前 (12-04)回复
  2. #3

    Contact him for any type of hacking, he is a professional hacker that specializes in exposing cheating spouses, and every other hacking related issues. he is a cyber guru, he helps catch cheating spouses by hacking their communications like call, Facebook, text, emails, Skype, whats-app and many more. I have used this service before and he did a very good job, he gave me every proof I needed to know that my fiancee was cheating. You can contact him on his email to help you catch your cheating spouse, or for any other hacking related problems, like hacking websites, bank statement, grades and many more. he will definitely help you, he has helped a lot of people, contact him on, Henryclarkethicalhacker@gmail.com, and you can Text/Call &WhatsApp: +1 (262)-236-7526, and figure out your relationship status. I wish you the best.

    Lucy Janet3个月前 (11-13)回复
  3. #2

    Tracking cellphones and getting an accurate report has been a bit worrisome, thanks to Jeffrey whose service helped me locate certain cellphones without breaking a sweat. His service made me know that the internet has become the most common method of cheating nowadays, either emotionally or physically. Taking a few extra steps in getting what would serve as proof for leaving a toxic relationship, to see who your spouse texts or chats with on social media isn’t a bad idea, I’d recommend you reach out to Jeffreyethicalhacker@gmail.com
    Text,call or whatsapp on: +1 (747)345-9036
    FGHJ

    dda liey5542个月前 (11-23)回复
  4. #1

    It took 11 months but I was able to get my money back. Earlier this year I got entangled with a military doctor serving in Syria via a hookup site, we chit-chatted for weeks and she introduced me to cryptocurrency that she has earned massively. I was tempted to try it as I was going through some financial challenges after my chaotic divorce. I did invest $393,000.00 AUD dollars which I got from my divorce settlement. That’s when I realized I have been swindled. Months later, I came across a testimonial, I never thought that after all these months I will be able to recover my lost Bitcoin from those scammers but ( Cybergenie@cyberservices.com )WhatsApp (+1) 252-512-0391). made that possible, here I am with a grateful heart to CYBER GENIE INTERCONTINENTAL…

    Russell B3周前 (01-09)回复