Skip to content

Commit

Permalink
Added Skaffold support
Browse files Browse the repository at this point in the history
  • Loading branch information
rofrano committed Aug 2, 2023
1 parent 71c4793 commit 5a1f77a
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 11 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ run: ## Run the service
##@ Kubernetes

.PHONY: cluster
# k3d cluster create --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
$(info Creating Kubernetes cluster with a registry and 1 node...)
k3d cluster create --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
docker container run -d --name registry.local -v local_registry:/var/lib/registry --restart always -p 5000:5000 registry:2
k3d cluster create --config k3d-config.yaml
docker network connect k3d-k3s-default registry.local

.PHONY: cluster-rm
cluster-rm: ## Remove a K3D Kubernetes cluster
$(info Removing Kubernetes cluster...)
k3d cluster delete
docker stop registry.local && docker rm registry.local

.PHONY: login
login: ## Login to IBM Cloud using yur api key
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,22 @@ kubectl -n default get secret all-icr-io -o yaml | sed 's/default/dev/g' | kubec

What the second command does is to get the `ImagePullSecret` named `all-icr-io` from the `default` namespace and running it through `sed` to change the `namespace:` to whatever is needed, and applying it to the `dev` namespace.

### Use with Minikube

In order to use Minikube you need to enable the ingress and registry addons.

Here are the commands to get `minikube` working:

```bash
minikube start
minikube addons enable ingress
minikube addons enable registry
```

You can also specify these are start up with:

```bash
minikube start --addons ingress --addons registry
```

See Minikube [documentation](https://minikube.sigs.k8s.io/docs/start/) for reference.
8 changes: 7 additions & 1 deletion deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
restartPolicy: Always
containers:
- name: hitcounter
image: cluster-registry:32000/hitcounter:1.0
image: registry.local:5000/hitcounter:1.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
Expand All @@ -34,3 +34,9 @@ spec:
name: redis-creds
key: uri
resources:
limits:
cpu: "0.25"
memory: "64Mi"
requests:
cpu: "0.10"
memory: "32Mi"
12 changes: 12 additions & 0 deletions deploy/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv0001
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: /data/pv0001
storageClassName: ""
31 changes: 23 additions & 8 deletions deploy/redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,31 @@ spec:
volumeMounts:
- name: redis-storage
mountPath: /data
# resources:
# limits:
# cpu: "0.25"
# memory: "64Mi"
# requests:
# cpu: "0.10"
# memory: "32Mi"
resources:
limits:
cpu: "0.50"
memory: "64Mi"
requests:
cpu: "0.25"
memory: "32Mi"
volumes:
- name: redis-storage
emptyDir: {}
persistentVolumeClaim:
claimName: redis-data
# emptyDir: {}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redis-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ""

---
apiVersion: v1
Expand Down
17 changes: 17 additions & 0 deletions k3d-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# k3d cluster create --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
---
apiVersion: k3d.io/v1alpha5
kind: Simple
# name: devops
servers: 1
agents: 1
ports:
- port: 8080:80
nodeFilters:
- loadbalancer
registries:
config: |
mirrors:
"registry.local:5000":
endpoint:
- http://registry.local:5000
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ green==3.4.3
coverage==7.1.0

# Utilities
httpie==3.2.1
httpie==3.2.2
20 changes: 20 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: skaffold/v4beta6
kind: Config
metadata:
name: hitcounter
build:
artifacts:
- image: registry.local:5000/hitcounter
docker:
dockerfile: Dockerfile
test:
- context: .
image: hitcounter
custom:
- command: DATABASE_URI=redis://localhost:6379/0 green
manifests:
rawYaml:
- deploy/**
# kustomize:
# paths:
# - "kubernetes/dev"

0 comments on commit 5a1f77a

Please sign in to comment.