How to build their own blog solo

Home effect

Here Insert Picture Description

Admin interface publish articles:
Here Insert Picture Description
own management capabilities, you can use github account login.
Solo is a small but beautiful blog system written in Java, feature-rich, plug-in technology, skin optional customizable, easy management, and community activists.
Here Insert Picture Description

This article describes the use of open-source blog Solo system set up your own blog on the cloud server, let me begin.

Premise of the need to access the public network IP port, you need to release the group added security in the console.

docker build

The first step is to install docker

yum install docker.x86_64 -y

After the installation is complete, start docker

systemctl start docker

Install mysql

Historical Reference article:
mysql image installation
Here Insert Picture Description
Here Insert Picture Description
, such as deployment mysql command with a few lines above, to map port 3306 to port 3307 on the host in the container. By the time you can use {public cloud server IP: 3307 to access the database}, after mysql deployed, first manually building a database (library name solo, character set utf8mb4, collation utf8mb4_general_ci)

Start solo container

Then start the container

docker run --detach --name solo --network=host \
    --env RUNTIME_DB="MYSQL" \
    --env JDBC_USERNAME="root" \
    --env JDBC_PASSWORD="123456" \
    --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
    --env JDBC_URL="jdbc:mysql://47.91.6.217:3307/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" \
    b3log/solo --listen_port=8080 --server_scheme=http --server_host=47.91.6.217
  • -detach namely -d parameter specifies the background,
  • -name Specifies the name of the vessel,
  • -env designated solo run the database system parameters,
  • -listen_port: process monitor port
  • -server_scheme: ultimate access protocol, if the anti generation services enabled HTTPS there also needs to https
  • -server_host: final public access to the domain name or IP, do not take port
  • -server_port: final port access, use the browser's default value of 80 or 443, then leave it blank

Mirroring using b3log / solo latest version, here for example, 47.91.6.217 my server public IP, with 47.91.6.217:8080 visit:
Here Insert Picture Description

k8s cluster deployment

mysql and solo use the pod is deployed, respectively, create mysql deployment management pod, mysql service providing service clusterIP for solo calls; create solo deployment management solo service, solo service provides a simple service discovery, solo ingress offers domain configuration, the entrance load balancing. If no domain name, you can be exposed directly through the port NodePort service.

mysql的deploy:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  template: 
    metadata:
      labels:
        name: mysql
    spec:
      containers:
      - name: mysql 
        image: mysql:5.7.28 
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "password"

mysql of service:

apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels: 
    name: mysql
spec:
  type: ClusterIP
  ports:
  - port: 3306
    protocol: TCP
    targetPort: 3306
    name: http
  selector:
    name: mysql

Only 的 deploy:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: solo
spec:
  replicas: 1
  template: 
    metadata:
      labels:
        name: solo
    spec:
      containers:
      - name: solo
        image: b3log/solo 
        imagePullPolicy: IfNotPresent
        args: ["--server_scheme=http", "--server_host=blog.liabio.cn"]
        ports:
        - containerPort: 8080
        env:
        - name: RUNTIME_DB
          value: MYSQL
        - name: JDBC_USERNAME
          value: solo
        - name: JDBC_PASSWORD
          value: solo-liabio
        - name: JDBC_DRIVER
          value: "com.mysql.cj.jdbc.Driver"
        - name: JDBC_URL
          value: "jdbc:mysql://10.100.133.125:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"

solo of service:

apiVersion: v1
kind: Service
metadata:
  name: solo
  labels: 
    name: solo
spec:
  type: ClusterIP
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
    name: http
  selector:
    name: solo

Here I used a ClusterIP of service, did not use the service NodePort, and is prepared to do because the load with ingress-nginx.

ingress-nginx deployment can refer to the history of the article:
K8S load balancer] [ingress-nginx deployment

only 的 ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: solo
spec:
  rules:
    - host: blog.liabio.cn
      http:
        paths:
          - backend:
              serviceName: solo
              servicePort: 8080
            path: /

Here Insert Picture Description
Since ingress-nginx hostNetwork deployed assembly for use, it can be through the public network IP: 80 port access.

NOTE: If you are deploying k8s, 1 may not carry nuclear 2G, 4G have at least two nuclear

Author concise

Author: a small bowl of soup, a love, a serious guy writing, currently maintaining the original number public: "My little bowl of soup," focus on writing golang, docker, kubernetes and other knowledge to enhance the hard power of articles, look forward to your attention . Reprinted Note: Be sure to indicate the source (note: from public number: My little bowl of soup, author: small bowl of soup)

Published 125 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/ll837448792/article/details/102879566