Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed May 2, 2024
1 parent 7dd5e6d commit 9a6c8e2
Show file tree
Hide file tree
Showing 51 changed files with 4,104 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test-tortoisectl-update: envtest

.PHONY: test-tortoisectl
test-tortoisectl: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout 30s -run Test_TortoiseCtlStop ./cmd/tortoisectl/test/...
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout 30s -v -run Test_TortoiseCtlStop ./cmd/tortoisectl/test/...

GINKGO ?= $(LOCALBIN)/ginkgo
GINKGO_VERSION ?= v2.1.4
Expand Down
11 changes: 8 additions & 3 deletions cmd/tortoisectl/commands/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ var stopCmd = &cobra.Command{

stoperService := stoper.New(client, deploymentService, podService)

err = stoperService.Stop(cmd.Context(), args, stopNamespace, stopAll, os.Stdout, stoper.NoLoweringResource)
opts := []stoper.StoprOption{}
if noLoweringResources {
opts = append(opts, stoper.NoLoweringResource)
}

err = stoperService.Stop(cmd.Context(), args, stopNamespace, stopAll, os.Stdout, opts...)
if err != nil {
return fmt.Errorf("failed to stop tortoise(s): %v", err)
}
Expand All @@ -77,7 +82,7 @@ var (
// Stop tortoise without lowering resource requests.
// If this flag is specified and the current Deployment's resource request(s) is lower than the current Pods' request mutated by Tortoise,
// this CLI patches the deployment so that changing tortoise to Off won't result in lowering the resource request(s), damaging the service.
noLoweringResource bool
noLoweringResources bool

// Path to KUBECONFIG
kubeconfig string
Expand All @@ -99,7 +104,7 @@ func init() {

stopCmd.Flags().StringVarP(&stopNamespace, "namespace", "n", "", "namespace to stop tortoise(s) in")
stopCmd.Flags().BoolVarP(&stopAll, "all", "A", false, "stop all tortoises in the specified namespace, or in all namespaces if no namespace is specified.")
stopCmd.Flags().BoolVar(&noLoweringResource, "no-lowering-resource", false, `Stop tortoise without lowering resource requests.
stopCmd.Flags().BoolVar(&noLoweringResources, "no-lowering-resources", false, `Stop tortoise without lowering resource requests.
If this flag is specified and the current Deployment's resource request(s) is lower than the current Pods' request mutated by Tortoise,
this CLI patches the deployment so that changing tortoise to Off won't result in lowering the resource request(s), damaging the service.`)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
metadata:
name: mercari-app-a
namespace: success-all-in-all-namespace
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: mercari
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: updated
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
imagePullPolicy: Always
name: app
resources:
requests:
cpu: "10"
memory: 10Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
- image: awesome-istio-proxy-image
imagePullPolicy: Always
name: istio-proxy
resources:
requests:
cpu: "4"
memory: 4Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
metadata:
name: mercari-app
namespace: success-all-in-all-namespace-2
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: mercari
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: updated
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
imagePullPolicy: Always
name: app
resources:
requests:
cpu: "10"
memory: 10Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
- image: awesome-istio-proxy-image
imagePullPolicy: Always
name: istio-proxy
resources:
requests:
cpu: "4"
memory: 4Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
metadata:
name: mercari-app-b
namespace: success-all-in-all-namespace
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: mercari
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: updated
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
imagePullPolicy: Always
name: app
resources:
requests:
cpu: "10"
memory: 10Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
- image: awesome-istio-proxy-image
imagePullPolicy: Always
name: istio-proxy
resources:
requests:
cpu: "4"
memory: 4Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
metadata:
name: mercari-app-c
namespace: success-all-in-all-namespace
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: mercari
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: updated
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
imagePullPolicy: Always
name: app
resources:
requests:
cpu: "10"
memory: 10Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
- image: awesome-istio-proxy-image
imagePullPolicy: Always
name: istio-proxy
resources:
requests:
cpu: "4"
memory: 4Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
metadata:
name: mercaritortoise-a
namespace: success-all-in-all-namespace
spec:
targetRefs:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app-a
updateMode: "Off"
status:
autoscalingPolicy:
- containerName: app
policy:
cpu: Horizontal
memory: Vertical
- containerName: istio-proxy
policy:
cpu: Horizontal
memory: Vertical
conditions:
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
recommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
- containerName: istio-proxy
maxRecommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
recommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
containerResourceRequests:
- containerName: app
resource:
cpu: "6"
memory: 3Gi
- containerName: istio-proxy
resource:
cpu: "4"
memory: 3Gi
tortoiseConditions:
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
message: the current number of replicas is not bigger than the preferred max
replica number
reason: ScaledUpBasedOnPreferredMaxReplicas
status: "False"
type: ScaledUpBasedOnPreferredMaxReplicas
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
message: HPA target utilization is updated
reason: HPATargetUtilizationUpdated
status: "True"
type: HPATargetUtilizationUpdated
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
message: The recommendation is provided
status: "True"
type: VerticalRecommendationUpdated
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
status: "False"
type: FailedToReconcile
containerResourcePhases:
- containerName: app
resourcePhases:
cpu:
lastTransitionTime: null
phase: Working
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
- containerName: istio-proxy
resourcePhases:
cpu:
lastTransitionTime: null
phase: Working
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
recommendations:
horizontal:
maxReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-01-01T00:00:00Z"
value: 20
minReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-01-01T00:00:00Z"
value: 5
targetUtilizations:
- containerName: app
targetUtilization:
cpu: 50
- containerName: istio-proxy
targetUtilization:
cpu: 75
vertical:
containerResourceRecommendation:
- RecommendedResource:
cpu: "6"
memory: 3Gi
containerName: app
- RecommendedResource:
cpu: "4"
memory: 3Gi
containerName: istio-proxy
targets:
horizontalPodAutoscaler: tortoise-hpa-mercari
scaleTargetRef:
kind: ""
name: ""
verticalPodAutoscalers:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
Loading

0 comments on commit 9a6c8e2

Please sign in to comment.