-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
submit home work week 4 (platform as a service -kubernetes) #64
Open
toanduc0671
wants to merge
1
commit into
vietstacker:main
Choose a base branch
from
toanduc0671:kubernetes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
Phase-1-Practices/Week-4/NguyenDucToan/Kubernetes - (platform as a service).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
# Kubernetes - (platform as a service) | ||
|
||
## set up an ubuntu VM | ||
|
||
- 2 CPUs or more | ||
- 2GB of free memory | ||
- 20GB of free disk space | ||
- Internet connection | ||
|
||
## **A. install kubernetes via mini-kube** | ||
1. requirement packet:</br > | ||
First update the system and get latest stable packet version for Ubuntu: | ||
|
||
```bash | ||
$ sudo apt update | ||
$ sudo apt upgrade | ||
``` | ||
|
||
- curl: | ||
```bash | ||
$ sudo apt install curl | ||
``` | ||
- docker: | ||
```bash | ||
$ sudo apt install docker.io | ||
``` | ||
|
||
2. install minikube on x86-64 Linux using Debian package: | ||
```bash | ||
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb | ||
$ sudo dpkg -i minikube_latest_amd64.deb | ||
``` | ||
|
||
3. install kubectl | ||
|
||
```bash | ||
$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl | ||
``` | ||
|
||
4. Start minikube | ||
```bash | ||
$ sudo usermod -aG docker $USER && newgrp docker | ||
$ minikube start --driver=docker | ||
``` | ||
 | ||
|
||
## **B. write manifest file to deploy wordpress on kubernetes** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Phần mariadb chưa có persistent volume. dữ liệu của database phải được lưu trong 1 persistent volume để tránh mất mát dữ liệu khi pod bị chết |
||
|
||
1. create mariadb.yaml | ||
```bash | ||
$ gedit mariadb.yaml | ||
``` | ||
``` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mariadb | ||
labels: | ||
app: mariadb | ||
user: pinpoint | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mariadb | ||
tier: mariadb | ||
template: | ||
metadata: | ||
labels: | ||
app: mariadb | ||
tier: mariadb | ||
spec: | ||
containers: | ||
- name: mariadb | ||
image: bitnami/mariadb:latest | ||
ports: | ||
- containerPort: 3306 | ||
env: | ||
- name: MYSQL_ROOT_PASSWORD | ||
value: " " | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mariadb-svc | ||
labels: | ||
user: pinpoint | ||
spec: | ||
selector: | ||
app: mariadb | ||
type: ClusterIP | ||
ports: | ||
- port: 3306 | ||
targetPort: 3306 | ||
``` | ||
|
||
2. create wordpress.yaml | ||
```bash | ||
$ gedit wordpress.yaml | ||
``` | ||
|
||
``` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: wordpress | ||
labels: | ||
app: wordpress | ||
user: pinpoint | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: wordpress | ||
tier: wordpress | ||
template: | ||
metadata: | ||
labels: | ||
app: wordpress | ||
tier: wordpress | ||
spec: | ||
containers: | ||
- name: wordpress | ||
image: bitnami/wordpress:latest | ||
ports: | ||
- containerPort: 80 | ||
env: | ||
- name: WORDPRESS_DB_HOST | ||
value: "mariadb-svc" | ||
- name: WORDPRESS_DB_USER | ||
value: "root" | ||
- name: WORDPRESS_DB_PASSWORD | ||
value: " " | ||
- name: WORDPRESS_DB_NAME | ||
value: "wp-test" | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: wordpress-svc | ||
labels: | ||
user: pinpoint | ||
spec: | ||
selector: | ||
app: wordpress | ||
type: ClusterIP | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
``` | ||
|
||
3. apply: | ||
```bash | ||
$ kubectl apply -f mariadb.yaml | ||
$ kubectl apply -f wordpress.yaml | ||
``` | ||
 | ||
|
||
 | ||
|
||
## **C. result** | ||
|
||
```bash | ||
$ kubectl get pods | ||
``` | ||
 | ||
|
||
```bash | ||
$ kubectl get service | ||
``` | ||
 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chưa show các thành phần của k8s