httpd部署

Posted fourw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了httpd部署相关的知识,希望对你有一定的参考价值。

创建共享存储目录

yum install -y rpcbind nfs-utils
创建共享目录
mkdir -p /home/sharedir/www
修改目录权限
chmod 0755 -R sharedir
修改NFS配置文件
vi /etc/exports
/home/sharedir 192.168.2.0(rw,no_root_squash,no_all_squash,sync)
启动nfs:systemctl start nfs

pv创建文档
vi httpd-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: httpd-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  nfs:
    path: /home/sharedir/www
    server: 192.168.2.120

pvc创建文档
vi httpd-pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: httpd-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

httpd创建文件
vi httpd.yaml

apiVersion: v1
kind: Service
metadata:
  name: httpd
spec:
  type: NodePort
  ports:
  - port: 80
    nodePort: 32222
    targetPort: 80
  selector:
    app: httpd
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd
spec:
  selector:
    matchLabels:
      app: httpd
  template:
    metadata:
      labels:
        app: httpd
    spec:
      containers:
      - name: httpd
        image: httpd
        ports:
        - name: httpd
          containerPort: 80
        volumeMounts:
        - name: httpd-persistent-storage
          mountPath: /usr/local/apache2/htdocs
      volumes:
      - name: httpd-persistent-storage
        persistentVolumeClaim:
          claimName: httpd-pvc

执行资源创建
kubectl apply -f httpd-pv.yaml
kubectl apply -f httpd-pvc.yaml
kubectl apply -f httpd.yaml

查看容器
[root@master mysql]# kubectl get pod
NAME READY STATUS RESTARTS AGE
httpd-65c5d64bd7-pmwwr 1/1 Running 0 2m19s

查看服务
[root@master mysql]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
httpd NodePort 10.103.239.58 <none> 80:32222/TCP 22m

进入httpd容器
[root@master mysql]# kubectl exec -it httpd-65c5d64bd7-pmwwr bash
root@httpd-65c5d64bd7-pmwwr:/usr/local/apache2#

访问站点:
http://192.168.2.122:32222/

修改副本数量

kubectl scale deployment httpd --replicas=2

 

以上是关于httpd部署的主要内容,如果未能解决你的问题,请参考以下文章

安装httpd过程,将网站部署到httpd过程

ansible自动化安装及部署httpd

Apache httpd server部署

Apache httpd server部署

httpd部署

部署SaltStack及批量安装httpd服务