Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
updated kafka
  • Loading branch information
darthkali committed Feb 2, 2023
1 parent 68fe227 commit ca40ecd
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 109 deletions.
169 changes: 98 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,93 +3,150 @@
The Kubernetes config repository for the corresponding MicroKino Microservices
https://github.com/fh-erfurt/MicroKino

## Hinweis
Unter Verwendung von Linux muss ggf. mit `sudo` die Berechitung erteilt werden.

## Einmaliges Setup

Dies folgenden Schritte müssen nur einmalig durchgeführt werden und sind ggf schon auf eurem System vorhanden.

## Setup
### Package-Managers:
**Mac**
- [Homebrew](https://brew.sh/)

**Windows**
- [Chocolatey](https://chocolatey.org/)

### Packages:
#### Helm

### Kind

**Mac**
```bash
brew install helm
``` shell
brew install kind
```

**Windows**
```bash
choco install kubernetes-helm
``` shell
choco install kind
```

**Linux**
``` shell
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
```

### Kubectl
**Mac**
https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/
``` shell
brew install kubectl
```

## Kind

### Installation
**Windows**
https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/
``` shell
choco install kubernetes-cli
```

### Kind
**Linux**
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
``` shell
sudo snap install kubectl --classic
```

### Docker
**Mac**

https://docs.docker.com/docker-for-mac/install/
``` shell
brew nstall kind
brew install docker
```

**Windows**

https://docs.docker.com/docker-for-windows/install/
``` shell
choco install kind
choco install docker-desktop
```

### Kubectl
**Linux**
Für Linux sind mehrere Schritte nötig, diese sind auf der Docker-Website beschrieben:
https://docs.docker.com/engine/install/ubuntu/

**Mac**

https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/
### Erzeuge Personal Access Token (PAT) auf GitHub
- Einstellungen -> Developer Settings -> Personal Access Tokens -> Generate new token
- read:packages

### Secrets erstellen
https://dev.to/asizikov/using-github-container-registry-with-kubernetes-38fb

#### 1. base64 encode PAT

``` shell
brew install kubectl
echo -n "<github-username>:<personal-access-token" | base64
```
> output = base-64-encoded-pat
**Windows**
```shell
echo -n '{"auths":{"ghcr.io":{"auth":"<base-64-encoded-pat>"}}}' | base64
```
> output = base-64-encoded-docker-config
#### 2. Secret zu kubernetes hinzufügen

https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/
Generate `dockerconfigjson.yaml` file if not exists and add the base64 encoded PAT to the field `data.dockerconfigjson`

``` yaml
kind: Secret
type: kubernetes.io/dockerconfigjson
apiVersion: v1
metadata:
name: dockerconfigjson-github-com
labels:
app: app-name
data:
.dockerconfigjson: <base-64-encoded-docker-config>
```
### Login in Github Container Registry
``` shell
choco install kubernetes-cli
docker login ghcr.io -u <github-username> -p <personal-access-token>
```
## Starten des Clusters
dem deploy.sh Script im root Ordner passende Rechte geben (muss nur einmalig gemacht werden)
``` shell
chmod +x deploy.sh
```

### Create Cluster

With default name `kind`

Starten des Kubernetes Clusters über die Konfigurationsdatei (deploy.sh)
``` shell
kind create cluster
./deploy.sh
```

With custom name `microkino-cluster`

``` shell
kind create cluster --name microkino-cluster
Wenn alle Pods laufen, dann muss noch das PortForwarding eingerichtet werden:
```shell
kubectl port-forward --address 0.0.0.0 service/traefik 8000:8000 8080:8080 443:4443 -n default
```

get kind clusters


---
## Zusätzliche Kommandos
### Create Cluster
Mit Standardnamen `kind`

``` shell
kind get clusters
kind create cluster
```

get nodes
Mit benutzerdefinierten Namen `microkino-cluster`

``` shell
kubectl get nodes
kind create cluster --name microkino-cluster
```

#### create Cluster with config
Mit Konfigdatei

Config File `kind-config.yaml`

Expand All @@ -105,50 +162,20 @@ nodes:
kind create cluster --config kind-config.yaml
```


### Delete Cluster
### Kind Cluster anzeigen

``` shell
kind delete cluster --name microkino-cluster
kind get clusters
```

### Secrets
https://dev.to/asizikov/using-github-container-registry-with-kubernetes-38fb

#### 1. generate Personal Access Token (PAT) on GitHub
- read:packages

#### 2. base64 encode PAT
### Nodes anzeigen

``` shell
echo -n "<github-username>:<personal-access-token" | base64
```
> output = base-64-encoded-pat
```shell
echo -n '{"auths":{"ghcr.io":{"auth":"<base-64-encoded-pat>"}}}' | base64
```
> output = base-64-encoded-docker-config
#### 3. Add secret to kubernetes
Generate `dockerconfigjson.yaml` file if not exists and add the base64 encoded PAT to the field `data.dockerconfigjson`

``` yaml
kind: Secret
type: kubernetes.io/dockerconfigjson
apiVersion: v1
metadata:
name: dockerconfigjson-github-com
labels:
app: app-name
data:
.dockerconfigjson: <base-64-encoded-docker-config>
kubectl get nodes
```

### Create Deployment
### Cluster Löschen

``` shell
➜ k create deployment postgres --image=postgres:latest --dry-run=client -o=yaml > postgres-deployment.yml
kind delete cluster --name microkino-cluster
```


3 changes: 0 additions & 3 deletions bookingservice/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ spec:
value: postgres
image: ghcr.io/fh-erfurt/microkino:bookingservice
imagePullPolicy: Always
# ports:
# - name: web
# containerPort: 8090
imagePullSecrets:
- name: dockerconfigjson-github-com
1 change: 0 additions & 1 deletion bookingservice/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: booking-service

spec:
ports:
- protocol: TCP
Expand Down
3 changes: 0 additions & 3 deletions cinemaservice/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ spec:
value: postgres
image: ghcr.io/fh-erfurt/microkino:cinemaservice
imagePullPolicy: Always
# ports:
# - name: web
# containerPort: 8090
imagePullSecrets:
- name: dockerconfigjson-github-com
1 change: 0 additions & 1 deletion cinemaservice/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: cinema-service

spec:
ports:
- protocol: TCP
Expand Down
3 changes: 0 additions & 3 deletions kafka/kafka-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ apiVersion: v1
kind: Service
metadata:
name: kafka-service
# labels:
# name: kafka
spec:
selector:
name: kafka
ports:
# - name: kafka-port
- port: 9092
protocol: TCP
targetPort: 9092
9 changes: 0 additions & 9 deletions kafka/zookeper-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ apiVersion: v1
kind: Service
metadata:
name: zookeeper-service
# labels:
# name: zookeeper
spec:
selector:
name: zookeeper
ports:
- port: 2181
protocol: TCP
targetPort: 2181
# - name: client
# - name: follower
# port: 2888
# protocol: TCP
# - name: leader
# port: 3888
# protocol: TCP
8 changes: 0 additions & 8 deletions kind-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,3 @@ nodes:
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
# extraPortMappings:
# - containerPort: 80
# hostPort: 80
# protocol: TCP
# - containerPort: 443
# hostPort: 443
# protocol: TCP
# - role: worker
3 changes: 0 additions & 3 deletions movieservice/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ spec:
value: kafka-service:9092
image: ghcr.io/fh-erfurt/microkino:movieservice
imagePullPolicy: Always
# ports:
# - name: web
# containerPort: 8090
imagePullSecrets:
- name: dockerconfigjson-github-com
1 change: 0 additions & 1 deletion movieservice/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: movie-service

spec:
ports:
- protocol: TCP
Expand Down
3 changes: 0 additions & 3 deletions showservice/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ spec:
value: kafka-service:9092
image: ghcr.io/fh-erfurt/microkino:showservice
imagePullPolicy: Always
# ports:
# - name: web
# containerPort: 8090
imagePullSecrets:
- name: dockerconfigjson-github-com
1 change: 0 additions & 1 deletion showservice/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: show-service

spec:
ports:
- protocol: TCP
Expand Down
2 changes: 0 additions & 2 deletions traefik/deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: ServiceAccount
metadata:
namespace: default
name: traefik-ingress-controller

---
kind: Deployment
apiVersion: apps/v1
Expand All @@ -12,7 +11,6 @@ metadata:
name: traefik
labels:
app: traefik

spec:
replicas: 1
selector:
Expand Down

0 comments on commit ca40ecd

Please sign in to comment.