This commit is contained in:
@@ -13,6 +13,6 @@ jobs:
|
||||
- name: Push to registry
|
||||
run: docker push registry.knatofs.se/go-cart-actor
|
||||
- name: Deploy to Kubernetes
|
||||
run: kubectl apply -f deployment.yaml -n cart
|
||||
run: kubectl apply -f deployment/deployment.yaml -n cart
|
||||
- name: Rollout
|
||||
run: kubectl rollout restart deployment/cart-actor -n cart
|
||||
@@ -1,27 +1,3 @@
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: cart-discovery
|
||||
rules:
|
||||
- apiGroups: [""] # "" indicates the core API group
|
||||
resources: ["pods","services"]
|
||||
verbs: ["get", "watch", "list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: cart-discovery-binding
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: default
|
||||
namespace: cart
|
||||
apiGroup: ""
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: cart-discovery
|
||||
apiGroup: ""
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -37,7 +13,7 @@ spec:
|
||||
metadata:
|
||||
labels:
|
||||
app: cart-actor
|
||||
pool: cart
|
||||
actor-pool: cart
|
||||
spec:
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
@@ -56,6 +32,7 @@ spec:
|
||||
server: 10.10.1.10
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
serviceAccountName: default
|
||||
containers:
|
||||
- image: registry.knatofs.se/go-cart-actor:latest
|
||||
name: cart-actor
|
||||
@@ -129,15 +106,3 @@ spec:
|
||||
name: cart-actor
|
||||
port:
|
||||
number: 8080
|
||||
---
|
||||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: cart-scaler
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
kind: Deployment
|
||||
name: cart-actor
|
||||
minReplicas: 1
|
||||
maxReplicas: 5
|
||||
targetCPUUtilizationPercentage: 50
|
||||
22
deployment/roles.yaml
Normal file
22
deployment/roles.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cart-discovery
|
||||
rules:
|
||||
- apiGroups: [""] # "" indicates the core API group
|
||||
resources: ["pods","services"]
|
||||
verbs: ["get", "watch", "list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: cart-discovery-binding
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: default
|
||||
namespace: cart
|
||||
apiGroup: ""
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: cart-discovery
|
||||
apiGroup: ""
|
||||
11
deployment/scaling.yaml
Normal file
11
deployment/scaling.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: cart-scaler
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
kind: Deployment
|
||||
name: cart-actor
|
||||
minReplicas: 1
|
||||
maxReplicas: 5
|
||||
targetCPUUtilizationPercentage: 50
|
||||
@@ -17,7 +17,7 @@ func TestDiscovery(t *testing.T) {
|
||||
t.Errorf("Error creating client: %v", err)
|
||||
}
|
||||
d := NewK8sDiscovery(client)
|
||||
res, err := d.DiscoverInNamespace("cart")
|
||||
res, err := d.DiscoverInNamespace("")
|
||||
if err != nil {
|
||||
t.Errorf("Error discovering: %v", err)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func (k *K8sDiscovery) Discover() ([]string, error) {
|
||||
}
|
||||
func (k *K8sDiscovery) DiscoverInNamespace(namespace string) ([]string, error) {
|
||||
pods, err := k.client.CoreV1().Pods(namespace).List(k.ctx, metav1.ListOptions{
|
||||
//LabelSelector: "pool=cart",
|
||||
LabelSelector: "actor-pool=cart",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user