Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to deploy your own web platform with K8s

Shulou Source: shulou.com Published: 2022-06-01 15:33:00 10月03日 Update

This article mainly explains "how to deploy your own web platform with K8s". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to deploy your own web platform with K8s.

1. Create a mariadb image and initialize the database in Dockerfile. Source code:

Https://github.com/zhanggq/mariadb

two。 Create your own web image, which is written in go at the back end and amaze at the front end. Open port 8082 is not available for the source code.

3. Create and paste yaml on Dashboard to start mariadb rc

ApiVersion: v1

Kind: ReplicationController

Metadata:

Name: mysql

Spec:

Replicas: 1

Selector:

App: mysql

Template:

Metadata:

Labels:

App: mysql

Spec:

Containers:

-image: registry.cn-hangzhou.aliyuncs.com/zhanggq/mariadb:v10.1

Name: mysql

Resources:

Limits:

Cpu: "2"

Memory: 2Gi

Ports:

-containerPort: 3306

Env:

-name: MYSQL_ROOT_PASSWORD

Value: "123456"

4. Start mariadb svc

ApiVersion: v1

Kind: Service

Metadata:

Name: mysql

Spec:

Ports:

-name: mysql-svc

Port: 3306

TargetPort: 3306

NodePort: 31101

Selector:

App: mysql

Type: NodePort

5. Start amaze rc

ApiVersion: v1

Kind: ReplicationController

Metadata:

Name: amaze

Spec:

Replicas: 1

Selector:

App: amaze

Template:

Metadata:

Labels:

App: amaze

Spec:

Containers:

-image: registry.cn-hangzhou.aliyuncs.com/zhanggq/amaze:v1.0

Name: amaze

Resources:

Limits:

Cpu: "1"

Memory: 1Gi

Ports:

-containerPort: 8082

6. Start amaze svc

ApiVersion: v1

Kind: Service

Metadata:

Name: amaze

Spec:

Ports:

-name: amaze-svc

Port: 8082

TargetPort: 8082

NodePort: 30082

Selector:

App: amaze

Type: NodePort

Problems encountered

1. Docker launches the container and reports an error:

Docker: Error response from daemon: mkdir / var/lib/docker/overlay/64d4cbac6ef69d5b84fc753e83dc2849f14e43177d0e9d

A532eb61499ce7e2fc-init/merged/dev/shm: invalid argument.

Solution: upgrade the kernel

Original kernel Kernel Version: 3.10.0-229.el7.x86_64

Upgraded kernel 4.6.0-1.el7.elrepo.x86_64

two。 Manually change the configuration in the web application and remotely connect to the mysql database 10.233.104.69

At this point, I believe you have a deeper understanding of "how to deploy your own web platform with K8s". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Platform kernel content data database source code mirror production upgrade learning practical deeper interest front-end method practical practical container manual easy to operate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi vpn Xiaomi Apple