Update kubernetes demo/config for example
A couple of changes to make the kubernetes config work and follow best practices. - Use `deployment` instead of `pod`. - Use correct image names. After these changes, running `kubectl create -f demo/config/` creates a working deployment/service.
This commit is contained in:
parent
ef9bc21b8f
commit
94c7154683
|
|
@ -12,6 +12,8 @@ The pod is composed of 3 containers that share directories using 2 volumes:
|
|||
|
||||
## Usage
|
||||
|
||||
### Build demo containers (Optional)
|
||||
|
||||
Build the demo containers, and push them to a registry
|
||||
|
||||
```
|
||||
|
|
@ -20,11 +22,14 @@ docker build -t <some-registry>/hugo hugo/
|
|||
docker push <some-registry>/hugo <some-registry>/git-sync
|
||||
```
|
||||
|
||||
If you end up using a different registry, be sure to update `config/deployment.yaml`.
|
||||
|
||||
###
|
||||
|
||||
Create the pod and the service for the blog
|
||||
|
||||
```
|
||||
kubectl pods create config/pod.yaml
|
||||
kubectl services create config/service.yaml
|
||||
kubectl create -f config
|
||||
```
|
||||
|
||||
Open the service external ip in your browser
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: blog
|
||||
labels:
|
||||
name: blog
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
name: blog
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: blog
|
||||
spec:
|
||||
containers:
|
||||
- name: git-sync
|
||||
image: staging-k8s.gcr.io/git-sync-amd64:v2.0.6
|
||||
imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /git
|
||||
env:
|
||||
- name: GIT_SYNC_REPO
|
||||
value: https://github.com/kubernetes/git-sync.git
|
||||
- name: GIT_SYNC_DEST
|
||||
value: git-sync
|
||||
- name: hugo
|
||||
image: k8s.gcr.io/hugo
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /src
|
||||
- name: html
|
||||
mountPath: /dest
|
||||
env:
|
||||
- name: HUGO_SRC
|
||||
value: /src/git-sync/demo/blog
|
||||
- name: HUGO_BUILD_DRAFT
|
||||
value: "true"
|
||||
- name: HUGO_BASE_URL
|
||||
value: example.com
|
||||
- name: nginx
|
||||
image: nginx
|
||||
volumeMounts:
|
||||
- name: html
|
||||
mountPath: /usr/share/nginx/html
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumes:
|
||||
- name: markdown
|
||||
emptyDir: {}
|
||||
- name: html
|
||||
emptyDir: {}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
labels:
|
||||
name: blog
|
||||
name: blog-pod
|
||||
spec:
|
||||
containers:
|
||||
- name: git-sync
|
||||
image: k8s.gcr.io/git-sync:v2.0.4
|
||||
imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /git
|
||||
env:
|
||||
- name: GIT_SYNC_REPO
|
||||
value: https://github.com/GoogleCloudPlatform/kubernetes.git
|
||||
- name: GIT_SYNC_DEST
|
||||
value: git
|
||||
- name: hugo
|
||||
image: k8s.gcr.io/hugo
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /src
|
||||
- name: html
|
||||
mountPath: /dest
|
||||
env:
|
||||
- name: HUGO_SRC
|
||||
value: /src/git-sync/demo/blog
|
||||
- name: HUGO_BUILD_DRAFT
|
||||
value: "true"
|
||||
- name: HUGO_BASE_URL
|
||||
value: example.com
|
||||
- name: nginx
|
||||
image: nginx
|
||||
volumeMounts:
|
||||
- name: html
|
||||
mountPath: /usr/share/nginx/html
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumes:
|
||||
- name: markdown
|
||||
emptyDir: {}
|
||||
- name: html
|
||||
emptyDir: {}
|
||||
Loading…
Reference in New Issue