├── .gitignore ├── LICENSE ├── README.md ├── dashboard ├── 00-sa.yaml ├── 01-crb.yaml └── getsecret.sh ├── extra └── autoscaling.yaml ├── ingress-nginx └── service-nodeport.yaml ├── kind-test-config.yaml ├── metrics-server ├── aggregated-metrics-reader.yaml ├── auth-delegator.yaml ├── auth-reader.yaml ├── metrics-apiservice.yaml ├── metrics-server-deployment.yaml ├── metrics-server-service.yaml └── resource-reader.yaml ├── mysql ├── secret.yaml ├── service.yaml └── statefulset.yaml └── wordpress ├── deployment.yaml ├── ingress.yaml └── service.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | *.sql 27 | *.sqlite 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | *.bak -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Crash Course 2 | 3 | Kubernetes Crash Course Blog Post(KR) - no link yet 4 | 5 | ## Prerequisite 6 | > _Requirement: Mac model 2010+, OS 10.12+_ 7 | ### Docker 8 | 9 | Install **_[docker for mac](https://docs.docker.com/docker-for-mac/install/)._** 10 | Follow **_[docker guide](https://docs.docker.com/docker-for-mac/#advanced)_** to increase resource limit(need to set memory to 8GB+). 11 | 12 | ### Go 13 | Install **_Go_** download from **_[golang.org]_** 14 | You can manage **_Go_** verions with **_[gvm]_** 15 | 16 | ### Kubectl 17 | ### Install with Homebrew on macOS 18 | brew install kubernetes-cli 19 | 20 | ### download kubectl 1.16.0 21 | curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/darwin/amd64/kubectl 22 | 23 | chmod -x ./kubectl 24 | 25 | mv ./kubectl /usr/local/bin/kubectl 26 | 27 | ### if kubectl isn't executable 28 | chmod 755 /usr/local/bin/kubectl 29 | 30 | ### KIND 31 | 32 | Refer to _**[KIND](https://github.com/kubernetes-sigs/kind)**_ for more details 33 | 34 | GO111MODULE="on" go get sigs.k8s.io/kind@v0.5.1 35 | 36 | export PATH="$PATH:$(go env GOPATH)/bin" 37 | 38 | ### Aliases 39 | 40 | alias k='kubectl' 41 | 42 | alias chrome="/Applications/Google\\ \\Chrome.app/Contents/MacOS/Google\\ \\Chrome" 43 | 44 | 45 | ### Useful Tools 46 | 47 | _kubectl_ command shell _**[auto-completion]**_ 48 | 49 | ### for oh-my-zsh 50 | plugins=(... kubectl) 51 | 52 | * k8s context/namespace changer _**[kubectx/kubens]**_ 53 | * Awesome k8s shell prompt _**[kube ps1](https://github.com/jonmosco/kube-ps1)**_ 54 | * Very cool k8s CLI manage tool _**[k9s]**_ 55 | * Multiple pods log tool for k8s _**[stern]**_ 56 | 57 | ## Practice 58 | 59 | ### Create k8s multi-node cluster with KIND 60 | Will create 1 master and 2 worker nodes. 61 | 62 | kind create cluster --name kind-m --config kind-test-config.yaml 63 | 64 | ### Change k8s config 65 | Add configs from _'.kube/kind-config-kind-m'_ to _'.kube/config'_ file 66 | or: 67 | 68 | export KUBECONFIG="$(kind get kubeconfig-path --name="kind-m")" 69 | 70 | > **Note**: k8s _config_ file may contain multiple configs. 71 | > 72 | ### Verify k8s cluster 73 | 74 | kubectl cluster-info 75 | kubectl get nodes 76 | kubectl get pods --all-namespaces 77 | 78 | 79 | ### Install metrics-server 80 | Refer to _**[metrics-server](https://github.com/kubernetes-incubator/metrics-server)**_ for more information 81 | 82 | kubectl apply -f ./metrics-server 83 | 84 | ### Install Ingress-nginx 85 | Installation _**[Guide](https://kubernetes.github.io/ingress-nginx/deploy/)**_ 86 | 87 | kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml 88 | 89 | ### create service with nodeport 32080, 32433 90 | kubectl apply -f ./ingress-nginx/ 91 | 92 | 93 | ### Deploy MariaDB(MySQL) for Wordpress - Stateful Sets 94 | Deploy _MariaDB:_ 95 | 96 | kubectl create namespace wordpress 97 | kubectl apply -f ./mysql 98 | 99 | ### Check Stateful Sets 100 | kubectl get sts -n wordpress 101 | kubectl describe sts mysql -n wordpress 102 | 103 | ### Deploy Wordpress - Deployment 104 | 105 | Deploy _Wordpress:_ 106 | 107 | ### get you local ip 108 | IP=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}') 109 | 110 | ### replace ingress host with your IP 111 | sed -i.bak "s/host.*/host: blog."$IP".nip.io/g" ./wordpress/ingress.yaml 112 | 113 | kubectl apply -f ./wordpress 114 | 115 | ### edit deployment 116 | kubectl edit deploy wordpress 117 | 118 | ### port forward to check if wordpress is running correctly 119 | WPOD=$(kubectl get -n wordpress pod -l app=wordpress -o jsonpath="{.items[0].metadata.name}") 120 | 121 | kubectl port-forward pod/$WPOD 8090:80 -n wordpress 122 | 123 | 124 | Scale in/out Deployments: 125 | 126 | kubectl scale deploy wordpress --replicas=3 -n wordpress 127 | kubectl scale deploy wordpress --replicas=1 -n wordpress 128 | 129 | ### check services for wordpress 130 | kubectl get svc -n wordpress 131 | 132 | ### check ingress 133 | kubectl get ingress -n wordpress 134 | 135 | ### other commands 136 | k explain deployment --recursive 137 | k explain svc --recursive 138 | k get pods -o wide --sort-by="{.spec.nodeName}" 139 | 140 | ### Expose Ingress 141 | Intall _socat_ to expose nodeport on local 80 port: 142 | 143 | docker run -d --name kind-proxy-80 \ 144 | --publish 80:80 \ 145 | --link kind-m-control-plane:target \ 146 | alpine/socat \ 147 | tcp-listen:80,fork,reuseaddr tcp-connect:target:32080 148 | 149 | ### Test 150 | 151 | Test with your own DNS: 152 | 153 | chrome http://blog.$IP.nip.io 154 | 155 | 156 | ### Delete resources and cluster 157 | kubectl --namespace=wordpress delete --all 158 | kubectl delete --namespace wordpress 159 | 160 | kind delete cluster --name kind-m 161 | 162 | ### remove socat 163 | docker rm -f kind-proxy-80 164 | 165 | 166 | ## Extra 167 | 168 | ### Web UI(Dashboard) 169 | Install _**[dashboard]:**_ 170 | 171 | kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml 172 | 173 | ### Run below to fix auth 174 | k apply -f ./dashboard 175 | 176 | ### Run below and copy hash code from token: 177 | ./dashboard/getsecret.sh 178 | 179 | ### Run below from another terminal: 180 | k proxy 181 | 182 | Click this _**[link](http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/)**_ to open dashboard in your web browser. 183 | 184 | To _disable_ session time-out: 185 | 186 | kubectl edit deployment kubernetes-dashboard -n kube-system 187 | 188 | ### add following after arg: 189 | - args: 190 | - --token-ttl=0 191 | 192 | 193 | ### Autoscaler 194 | 195 | ### metrics-server must be running 196 | kubectl apply -f ./extra 197 | 198 | ### Demo - ASCIINEMA 199 | [![asciicast](https://asciinema.org/a/gM5ljzLZHJcieRLrzyKdf7xjw.svg)](https://asciinema.org/a/gM5ljzLZHJcieRLrzyKdf7xjw) 200 | 201 | ### Debug 202 | 203 | Refer to _**[K8S Debug Services](https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/)**_ for details 204 | 205 | # Run alpine image to troubleshoot 206 | kubectl run -it --rm --restart=Never alpine --image=alpine sh 207 | 208 | # lookup service 209 | nslookup wordpress 210 | 211 | # check svc name/IP 212 | wget -SO- wordpress:8081 213 | wget -SO- :8081 214 | 215 | # check pod endpoint 216 | wget -SO- 217 | 218 | ### Blogs and Documentations 219 | 220 | subicura님의 _**[쿠버네티스 시작하기 블로그](https://subicura.com/2019/05/19/kubernetes-basic-1.html)**_ 221 | 222 | 223 | _**[Kubernetes Documentation(KR)](https://kubernetes.io/ko/docs/concepts/overview/what-is-kubernetes/)**_ 224 | 225 | K8S Deep Dive: API Server _**[Part1](https://blog.openshift.com/kubernetes-deep-dive-api-server-part-1/), [Part2](https://blog.openshift.com/kubernetes-deep-dive-api-server-part-2/), [Part3](https://blog.openshift.com/kubernetes-deep-dive-api-server-part-3a/)**_ 226 | 227 | _**[Google Container(KR)](https://cloud.google.com/containers/?hl=ko)**_ 228 | 229 | 230 | 이어형님 _**[딥다이브](https://engineering.linecorp.com/ko/blog/immutable-kubernetes-architecture-deepdive/)**_ 231 | 232 | 233 | Dockerfile _**[Best Practices](https://bit.ly/dockerbp)**_ 234 | 235 | 236 | [kubectx/kubens]: 237 | https://github.com/ahmetb/kubectx 238 | 239 | [auto-completion]: 240 | https://kubernetes.io/docs/tasks/tools/install-kubectl/?source=#enabling-shell-autocompletion 241 | 242 | [dashboard]: 243 | https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/ 244 | 245 | [KIND]: 246 | https://kind.sigs.k8s.io/docs/user/quick-start 247 | 248 | [golang.org]: 249 | https://golang.org/dl/ 250 | 251 | [gvm]: 252 | https://github.com/moovweb/gvm 253 | 254 | [Homebrew]: 255 | https://brew.sh/ 256 | 257 | [k9s]: 258 | https://k9ss.io/?fbclid=IwAR0MQO9yBF5iKpJlDkuSNtrWGy72zK81I-j071lrKQsV1DLhloOMknOLd64 259 | 260 | [stern]: 261 | https://github.com/wercker/stern 262 | -------------------------------------------------------------------------------- /dashboard/00-sa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: dash-admin 5 | namespace: kube-system 6 | -------------------------------------------------------------------------------- /dashboard/01-crb.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: dash-admin 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: cluster-admin 9 | subjects: 10 | - kind: ServiceAccount 11 | name: dash-admin 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /dashboard/getsecret.sh: -------------------------------------------------------------------------------- 1 | kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep dash-admin | awk '{print $1}') 2 | -------------------------------------------------------------------------------- /extra/autoscaling.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: autoscaling/v2beta2 2 | kind: HorizontalPodAutoscaler 3 | metadata: 4 | name: wordpress-scaler 5 | namespace: wordpress 6 | spec: 7 | scaleTargetRef: 8 | apiVersion: apps/v1 9 | kind: Deployment 10 | app: wordpress 11 | minReplicas: 3 12 | maxReplicas: 10 13 | metrics: 14 | - type: Resource 15 | resource: 16 | name: cpu 17 | target: 18 | type: Utilization 19 | averageUtilization: 50 -------------------------------------------------------------------------------- /ingress-nginx/service-nodeport.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ingress-nginx 5 | namespace: ingress-nginx 6 | labels: 7 | app.kubernetes.io/name: ingress-nginx 8 | app.kubernetes.io/part-of: ingress-nginx 9 | spec: 10 | type: NodePort 11 | ports: 12 | - name: http 13 | port: 80 14 | targetPort: 80 15 | protocol: TCP 16 | nodePort: 32080 17 | - name: https 18 | port: 443 19 | targetPort: 443 20 | protocol: TCP 21 | nodePort: 32433 22 | selector: 23 | app.kubernetes.io/name: ingress-nginx 24 | app.kubernetes.io/part-of: ingress-nginx 25 | 26 | -------------------------------------------------------------------------------- /kind-test-config.yaml: -------------------------------------------------------------------------------- 1 | # three node (two workers) cluster config 2 | kind: Cluster 3 | apiVersion: kind.sigs.k8s.io/v1alpha3 4 | nodes: 5 | - role: control-plane 6 | - role: worker 7 | - role: worker 8 | 9 | # uncomment below to expose nodeport on localhost:8080 10 | # extraPortMappings: 11 | # - containerPort: 31689 12 | # hostPort: 8080 13 | # listenAddress: "127.0.0.1" 14 | -------------------------------------------------------------------------------- /metrics-server/aggregated-metrics-reader.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRole 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: system:aggregated-metrics-reader 5 | labels: 6 | rbac.authorization.k8s.io/aggregate-to-view: "true" 7 | rbac.authorization.k8s.io/aggregate-to-edit: "true" 8 | rbac.authorization.k8s.io/aggregate-to-admin: "true" 9 | rules: 10 | - apiGroups: ["metrics.k8s.io"] 11 | resources: ["pods", "nodes"] 12 | verbs: ["get", "list", "watch"] 13 | -------------------------------------------------------------------------------- /metrics-server/auth-delegator.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: rbac.authorization.k8s.io/v1beta1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: metrics-server:system:auth-delegator 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: ClusterRole 9 | name: system:auth-delegator 10 | subjects: 11 | - kind: ServiceAccount 12 | name: metrics-server 13 | namespace: kube-system 14 | -------------------------------------------------------------------------------- /metrics-server/auth-reader.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: rbac.authorization.k8s.io/v1beta1 3 | kind: RoleBinding 4 | metadata: 5 | name: metrics-server-auth-reader 6 | namespace: kube-system 7 | roleRef: 8 | apiGroup: rbac.authorization.k8s.io 9 | kind: Role 10 | name: extension-apiserver-authentication-reader 11 | subjects: 12 | - kind: ServiceAccount 13 | name: metrics-server 14 | namespace: kube-system 15 | -------------------------------------------------------------------------------- /metrics-server/metrics-apiservice.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apiregistration.k8s.io/v1beta1 3 | kind: APIService 4 | metadata: 5 | name: v1beta1.metrics.k8s.io 6 | spec: 7 | service: 8 | name: metrics-server 9 | namespace: kube-system 10 | group: metrics.k8s.io 11 | version: v1beta1 12 | insecureSkipTLSVerify: true 13 | groupPriorityMinimum: 100 14 | versionPriority: 100 15 | -------------------------------------------------------------------------------- /metrics-server/metrics-server-deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: metrics-server 6 | namespace: kube-system 7 | --- 8 | apiVersion: apps/v1 9 | kind: Deployment 10 | metadata: 11 | name: metrics-server 12 | namespace: kube-system 13 | labels: 14 | k8s-app: metrics-server 15 | spec: 16 | selector: 17 | matchLabels: 18 | k8s-app: metrics-server 19 | template: 20 | metadata: 21 | name: metrics-server 22 | labels: 23 | k8s-app: metrics-server 24 | spec: 25 | serviceAccountName: metrics-server 26 | volumes: 27 | # mount in tmp so we can safely use from-scratch images and/or read-only containers 28 | - name: tmp-dir 29 | emptyDir: {} 30 | containers: 31 | # below command options are not suitable for production 32 | - command: 33 | - /metrics-server 34 | - --v=2 35 | - --kubelet-preferred-address-types=InternalIP 36 | - --kubelet-insecure-tls 37 | name: metrics-server 38 | image: k8s.gcr.io/metrics-server-amd64:v0.3.4 39 | imagePullPolicy: Always 40 | volumeMounts: 41 | - name: tmp-dir 42 | mountPath: /tmp 43 | 44 | -------------------------------------------------------------------------------- /metrics-server/metrics-server-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: metrics-server 6 | namespace: kube-system 7 | labels: 8 | kubernetes.io/name: "Metrics-server" 9 | kubernetes.io/cluster-service: "true" 10 | spec: 11 | selector: 12 | k8s-app: metrics-server 13 | ports: 14 | - port: 443 15 | protocol: TCP 16 | targetPort: 443 17 | -------------------------------------------------------------------------------- /metrics-server/resource-reader.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: system:metrics-server 6 | rules: 7 | - apiGroups: 8 | - "" 9 | resources: 10 | - pods 11 | - nodes 12 | - nodes/stats 13 | - namespaces 14 | verbs: 15 | - get 16 | - list 17 | - watch 18 | --- 19 | apiVersion: rbac.authorization.k8s.io/v1 20 | kind: ClusterRoleBinding 21 | metadata: 22 | name: system:metrics-server 23 | roleRef: 24 | apiGroup: rbac.authorization.k8s.io 25 | kind: ClusterRole 26 | name: system:metrics-server 27 | subjects: 28 | - kind: ServiceAccount 29 | name: metrics-server 30 | namespace: kube-system 31 | -------------------------------------------------------------------------------- /mysql/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mysql-pass 5 | namespace: wordpress 6 | type: Opaque 7 | data: 8 | password: a2luZHRlc3QxMjM= 9 | -------------------------------------------------------------------------------- /mysql/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mysql 5 | labels: 6 | name: mysql 7 | namespace: wordpress 8 | spec: 9 | ports: 10 | - port: 3306 11 | name: mysql 12 | targetPort: 3306 13 | protocol: TCP 14 | clusterIP: None 15 | selector: 16 | name: mysql 17 | 18 | -------------------------------------------------------------------------------- /mysql/statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta1 2 | kind: StatefulSet 3 | metadata: 4 | name: mysql 5 | labels: 6 | name: mysql 7 | namespace: wordpress 8 | spec: 9 | serviceName: mysql 10 | replicas: 1 11 | template: 12 | metadata: 13 | labels: 14 | name: mysql 15 | spec: 16 | terminationGracePeriodSeconds: 10 17 | containers: 18 | - name: mysql 19 | image: mariadb:latest 20 | ports: 21 | - containerPort: 3306 22 | name: mysql 23 | env: 24 | - name: MYSQL_ROOT_PASSWORD 25 | valueFrom: 26 | secretKeyRef: 27 | name: mysql-pass 28 | key: password 29 | volumeMounts: 30 | - name: db 31 | mountPath: /var/lib/mysql 32 | volumeClaimTemplates: 33 | - metadata: 34 | name: db 35 | spec: 36 | accessModes: [ "ReadWriteOnce" ] 37 | resources: 38 | requests: 39 | storage: 1Gi 40 | storageClassName: standard 41 | -------------------------------------------------------------------------------- /wordpress/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: wordpress 5 | labels: 6 | app: wordpress 7 | namespace: wordpress 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: wordpress 13 | strategy: 14 | type: Recreate 15 | template: 16 | metadata: 17 | labels: 18 | app: wordpress 19 | spec: 20 | containers: 21 | - name: wordpress 22 | image: wordpress 23 | ports: 24 | - containerPort: 80 25 | name: wordpress 26 | volumeMounts: 27 | - mountPath: /var/www/html 28 | name: my-vol 29 | env: 30 | - name: WORDPRESS_DB_PASSWORD 31 | valueFrom: 32 | secretKeyRef: 33 | name: mysql-pass 34 | key: password 35 | - name: WORDPRESS_DB_USER 36 | value: root 37 | - name: WORDPRESS_DB_HOST 38 | value: mysql 39 | volumes: 40 | - name: my-vol 41 | hostPath: 42 | path: "/mnt/data/web" 43 | -------------------------------------------------------------------------------- /wordpress/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: ingress-wordpress 5 | namespace: wordpress 6 | annotations: 7 | kubernetes.io/ingress.class: "nginx" 8 | nginx.ingress.kubernetes.io/proxy-body-size: "500m" 9 | spec: 10 | rules: 11 | - host: blog.192.168.0.242.nip.io 12 | http: 13 | paths: 14 | - backend: 15 | serviceName: wordpress 16 | servicePort: 8081 17 | -------------------------------------------------------------------------------- /wordpress/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | name: wordpress 6 | name: wordpress 7 | namespace: wordpress 8 | spec: 9 | ports: 10 | - port: 8081 11 | protocol: TCP 12 | targetPort: 80 13 | selector: 14 | app: wordpress 15 | --------------------------------------------------------------------------------