Httpd Deploy in Kubernetes: Difference between revisions
Jump to navigation
Jump to search
(15 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[Httpd Operations#Subjects|httpd Operations]] | * [[Httpd Operations#Subjects|httpd Operations]] | ||
* [[Httpd_Installation#Deploying_a_httpd_server_in_Kubernetes|httpd Installation]] | * [[Httpd_Installation#Deploying_a_httpd_server_in_Kubernetes|httpd Installation]] | ||
* [[Setting Up a Helm Repository in Kubernetes]] | |||
=Overview= | |||
This is a procedure to deploy httpd as a pod in Kubernetes and make it serve content form a local directory, mounted as "[[Kubernetes_Storage_Concepts#hostPath|hostPath]]". The procedure was written using Docker Desktop Kubernetes. | |||
=Playground= | |||
{{External|https://github.com/ovidiuf/playground/tree/master/kubernetes/httpd-serving-local-hostPath}} | |||
=Procedure= | |||
==Local Directory== | |||
Create a local directory that will host the content to be served by httpd. | |||
<syntaxhighlight lang='bash'> | |||
mkdir ~/runtime/httpd-root | |||
</syntaxhighlight> | |||
==Pod and Service Manifest== | |||
<syntaxhighlight lang='yaml'> | |||
apiVersion: v1 | |||
kind: Pod | |||
metadata: | |||
name: 'httpd-local' | |||
labels: | |||
function: 'httpd-server' | |||
spec: | |||
containers: | |||
- name: 'httpd' | |||
image: docker.io/ovidiufeodorov/httpd:latest | |||
volumeMounts: | |||
- name: 'httpd-local-root' | |||
mountPath: '/usr/local/apache2/htdocs' | |||
volumes: | |||
- name: 'httpd-local-root' | |||
hostPath: | |||
path: /Users/ovidiu/runtime/httpd-root | |||
--- | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: 'httpd-local' | |||
spec: | |||
type: 'LoadBalancer' | |||
selector: | |||
function: 'httpd-server' | |||
ports: | |||
- name: 'http' | |||
protocol: 'TCP' | |||
port: 80 | |||
targetPort: 80 | |||
</syntaxhighlight> | |||
==Deploy== | |||
<syntaxhighlight lang='bash'> | |||
kubectl apply -f ./httpd.yaml | |||
</syntaxhighlight> | |||
==Undeploy== | |||
<syntaxhighlight lang='bash'> | |||
kubectl delete pod httpd-local | |||
kubectl delete service httpd-local | |||
</syntaxhighlight> | |||
==Logs== | |||
httpd container image is configured to generate error and access logs at stdout/stderr. |
Latest revision as of 19:48, 15 December 2019
Internal
Overview
This is a procedure to deploy httpd as a pod in Kubernetes and make it serve content form a local directory, mounted as "hostPath". The procedure was written using Docker Desktop Kubernetes.
Playground
Procedure
Local Directory
Create a local directory that will host the content to be served by httpd.
mkdir ~/runtime/httpd-root
Pod and Service Manifest
apiVersion: v1
kind: Pod
metadata:
name: 'httpd-local'
labels:
function: 'httpd-server'
spec:
containers:
- name: 'httpd'
image: docker.io/ovidiufeodorov/httpd:latest
volumeMounts:
- name: 'httpd-local-root'
mountPath: '/usr/local/apache2/htdocs'
volumes:
- name: 'httpd-local-root'
hostPath:
path: /Users/ovidiu/runtime/httpd-root
---
apiVersion: v1
kind: Service
metadata:
name: 'httpd-local'
spec:
type: 'LoadBalancer'
selector:
function: 'httpd-server'
ports:
- name: 'http'
protocol: 'TCP'
port: 80
targetPort: 80
Deploy
kubectl apply -f ./httpd.yaml
Undeploy
kubectl delete pod httpd-local
kubectl delete service httpd-local
Logs
httpd container image is configured to generate error and access logs at stdout/stderr.