-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f5f127
Showing
23 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,35 @@ | ||
#!/bin/bash | ||
|
||
# pull an image from Docker Hub | ||
docker image pull ubuntu:latest | ||
|
||
# List all images | ||
docker images | ||
|
||
# Run a container interactively | ||
docker run -it ubuntu /bin/bash | ||
|
||
# Run a container in the background | ||
docker run -d ubuntu sleep 100 | ||
|
||
# List running containers | ||
docker container ls | ||
|
||
# List all containers on the systems | ||
docker container ls -a | ||
|
||
# list all networks | ||
docker network ls | ||
|
||
# create a network | ||
docker network create frontend | ||
docker network create backend | ||
|
||
# provision voting app | ||
docker run -d -p 6379:6379 --name redis --network backend redis | ||
docker run -d -p 5000:80 --name vote --network frontend docker/example-voting-app-vote | ||
docker network connect backend vote | ||
docker run -d --name db --network=backend -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.4 | ||
docker run -d --name worker --network=backend docker/example-voting-app-worker | ||
docker run -d --name result --network=frontend -p 5001:80 docker/example-voting-app-result | ||
docker network connect backend result |
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,13 @@ | ||
#!/bin/bash | ||
|
||
# install compose plugin | ||
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | ||
mkdir -p $DOCKER_CONFIG/cli-plugins | ||
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose | ||
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | ||
|
||
# Check compose version | ||
docker compose version | ||
|
||
# Run a compose service | ||
docker compose up |
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,35 @@ | ||
#!/bin/bash | ||
|
||
# Firewall rules | ||
ufw allow 22/tcp | ||
ufw allow 2376/tcp | ||
ufw allow 2377/tcp | ||
ufw allow 7946/tcp | ||
ufw allow 7946/udp | ||
ufw allow 4789/udp | ||
|
||
# Initialize swarm | ||
docker swarm init | ||
|
||
# Join swarm | ||
docker swarm join --token <Token> <Leader-IP>:2377 | ||
|
||
# Checlk swarm nodes | ||
docker node ls | ||
|
||
# Enabling swarm creates an overlay network | ||
docker network ls | ||
|
||
# Create a service | ||
docker service create --replicas 2 --name nginx --publish 8080:80 nginx:latest | ||
|
||
# Create declaratively | ||
docker stack deploy -c docker-stack.yaml voting-app | ||
|
||
# Inspect services | ||
docker stack services voting-app | ||
docker service ps voting-app_vote | ||
|
||
# Working with stack | ||
docker stack ps voting-app | ||
docker stack rm voting-app |
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,44 @@ | ||
services: | ||
redis: | ||
image: redis:latest | ||
networks: | ||
- backend | ||
|
||
vote: | ||
image: docker/example-voting-app-vote:latest | ||
ports: | ||
- 5000:80 | ||
networks: | ||
- frontend | ||
- backend | ||
depends_on: | ||
- redis | ||
|
||
db: | ||
image: postgres:9.4 | ||
environment: | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
networks: | ||
- backend | ||
|
||
worker: | ||
image: docker/example-voting-app-worker | ||
networks: | ||
- backend | ||
depends_on: | ||
- db | ||
|
||
result: | ||
image: docker/example-voting-app-result | ||
networks: | ||
- frontend | ||
- backend | ||
ports: | ||
- 5001:80 | ||
depends_on: | ||
- db | ||
- worker | ||
|
||
networks: | ||
frontend: | ||
backend: |
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,49 @@ | ||
version: "3.9" | ||
services: | ||
redis: | ||
image: redis:latest | ||
networks: | ||
- backend | ||
|
||
vote: | ||
image: docker/example-voting-app-vote:latest | ||
ports: | ||
- 5000:80 | ||
networks: | ||
- frontend | ||
- backend | ||
depends_on: | ||
- redis | ||
deploy: | ||
replicas: 2 | ||
|
||
db: | ||
image: postgres:9.4 | ||
environment: | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
networks: | ||
- backend | ||
|
||
worker: | ||
image: docker/example-voting-app-worker | ||
networks: | ||
- backend | ||
depends_on: | ||
- db | ||
|
||
result: | ||
image: docker/example-voting-app-result | ||
networks: | ||
- frontend | ||
- backend | ||
ports: | ||
- 5001:80 | ||
depends_on: | ||
- db | ||
- worker | ||
deploy: | ||
replicas: 2 | ||
|
||
networks: | ||
frontend: | ||
backend: |
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,7 @@ | ||
#!/bin/bash | ||
|
||
# Check if kubectl is working | ||
kubectl version --output=json | ||
|
||
# Get help | ||
kubectl explain pods |
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,9 @@ | ||
New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force | ||
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing | ||
|
||
$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) | ||
if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ | ||
[Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) | ||
} | ||
|
||
minikube start |
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,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
labels: | ||
app: nginx | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx |
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,8 @@ | ||
kubectl apply -f .\vote.yml | ||
kubectl apply -f .\result.yml | ||
|
||
kubectl get pods | ||
|
||
kubectl describe pods vote | ||
|
||
kubectl exec -it vote -- sh |
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,20 @@ | ||
apiVersion: apps/v1 | ||
kind: ReplicaSet | ||
metadata: | ||
name: myapp-replicaset | ||
labels: | ||
app: myapp | ||
spec: | ||
selector: | ||
matchLabels: | ||
tier: frontend | ||
replicas: 4 | ||
template: | ||
metadata: | ||
name: nginx-2 | ||
labels: | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx |
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,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp-deploment | ||
labels: | ||
tier: frontend | ||
app: nginx | ||
spec: | ||
selector: | ||
matchLabels: | ||
tier: frontend | ||
replicas: 3 | ||
template: | ||
metadata: | ||
name: nginx-2 | ||
labels: | ||
app: nginx | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx |
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,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: db | ||
name: db | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: "db-service" | ||
port: 5432 | ||
targetPort: 5432 | ||
selector: | ||
app: db | ||
|
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,33 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: db | ||
name: db | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: db | ||
template: | ||
metadata: | ||
labels: | ||
app: db | ||
spec: | ||
containers: | ||
- image: postgres:15-alpine | ||
name: postgres | ||
env: | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
value: postgres | ||
ports: | ||
- containerPort: 5432 | ||
name: postgres | ||
volumeMounts: | ||
- mountPath: /var/lib/postgresql/data | ||
name: db-data | ||
volumes: | ||
- name: db-data | ||
emptyDir: {} |
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,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: redis | ||
name: redis | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: "redis-service" | ||
port: 6379 | ||
targetPort: 6379 | ||
selector: | ||
app: redis | ||
|
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,28 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: redis | ||
name: redis | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
spec: | ||
containers: | ||
- image: redis:alpine | ||
name: redis | ||
ports: | ||
- containerPort: 6379 | ||
name: redis | ||
volumeMounts: | ||
- mountPath: /data | ||
name: redis-data | ||
volumes: | ||
- name: redis-data | ||
emptyDir: {} |
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,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: result | ||
name: result | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: "result-service" | ||
port: 5001 | ||
targetPort: 80 | ||
nodePort: 31001 | ||
selector: | ||
app: result |
Oops, something went wrong.