码迷,mamicode.com
首页 > 其他好文 > 详细

k8s安装常用软件的yaml文件

时间:2021-04-26 14:08:07      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:targe   sts   tps   mod   node   tor   yam   眼睛   软件   

参考网址:https://www.bejson.com (网站文件部分有坑,需要擦亮眼睛)

nginx

k8s版本:v1.20

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx
  namespace: test
spec:
  replicas: 1
  selector:
    matchLabels:
      run: my-nginx
  template:
    metadata:
      labels:
        run: my-nginx
    spec:
      containers:
        - name: my-nginx
          image: nginx
          ports:
            - containerPort: 80
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: 400m
              memory: 600Mi
            limits:
              cpu: 800m
              memory: 800Mi
      volumes:
        - name: myemptydir
          emptyDir: {}

MySQL

MySQL版本:8.0.23,k8s版本:v1.20

# cat PersistentVolumeClaim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-mysql-data
  namespace: test
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
  storageClassName: storage # 需要事先创建好存储类
# cat service.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-mysql # 名称要跟Deployment.yaml中的保持一致
  namespace: test
spec:
  type: NodePort
  selector:
    app: my-mysql
  ports:
    - port: 3306
      targetPort: 3306
      nodePort: 32306
# cat Deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-mysql
  namespace: test
  labels:
    app: my-mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mysql
  template:
    metadata:
      labels:
        app: my-mysql
    spec:
      volumes:
        - name: my-mysql-data
          persistentVolumeClaim:
            claimName: my-mysql-data
        - name: mysql-conf
          configMap:
            name: mysql-conf
      containers:
        - env:
            - name: MYSQL_ROOT_PASSWORD #root用户密码
              value: root
            - name: MYSQL_USER # 普通用户
              value: test
            - name: MYSQL_PASSWORD # 普通用户密码
              value: test
          image: ‘mysql:8.0.23‘
          imagePullPolicy: IfNotPresent
          name: my-mysql
          ports:
            - containerPort: 3306
              protocol: TCP
              name: http
          volumeMounts:
            - name: my-mysql-data
              mountPath: /var/lib/mysql
            - name: mysql-conf
              mountPath: /etc/mysql/mysql.conf.d
          resources:
            requests:
              cpu: 400m
              memory: 600Mi
            limits:
              cpu: 800m
              memory: 800Mi
# cat ConfigMap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-conf
  namespace: test
data:
  mysql.cnf: |
    [mysqld]

     pid-file        = /var/run/mysqld/mysqld.pid
     socket          = /var/run/mysqld/mysqld.sock
     datadir         = /var/lib/mysql
     
     symbolic-links=0
     sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

未完待续。。。

k8s安装常用软件的yaml文件

标签:targe   sts   tps   mod   node   tor   yam   眼睛   软件   

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14701386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!