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
type Repository struct { | |
apiRateLimitter *rate.Limiter | |
} | |
func NewRepository() *Repository { | |
return &Repository{ | |
apiRateLimitter: rate.NewLimiter(rate.Every(time.Second/time.Duration(config.GetInt("API_RPS"))), 1), | |
} | |
} |
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
# Deployment | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: your-deployment | |
namespace: your-namespace | |
labels: | |
app: your-application | |
spec: | |
replicas: ${REPLICAS_COUNT} |
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
metadata: | |
labels: | |
app: app-name | |
process: app-process | |
product: app-product |
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
REPLICAS_COUNT=$(kubectl -s $K8S_CLUSTER --token=$K8S_TOKEN -n $NAMESPACE get pods -l app=$YOUR_APP | grep -i running | wc -l | grep -oE "[0-9]+") | |
if [ $REPLICAS_COUNT -eq 0 ]; then | |
REPLICAS_COUNT=2 | |
fi | |
REPLICAS_COUNT=$REPLICAS_COUNT envsubst < deploy/your-deployment.yaml.template > your-deployment.yaml |
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
selector: | |
matchLabels: | |
app: app-name | |
process: app-process | |
product: app-product | |
minAvailable: 50% |
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
scaleTargetRef: | |
apiVersion: apps/v1beta1 | |
kind: Deployment | |
name: deploymentName | |
minReplicas: 6 | |
maxReplicas: 60 | |
targetCPUUtilizationPercentage: 50 |
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
resources: | |
requests: | |
memory: 1Gi | |
cpu: 1 | |
limits: | |
memory: 1Gi | |
cpu: 1 |
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
livenessProbe: | |
failureThreshold: 3 | |
httpGet: | |
path: /healthcheck/status | |
port: 3000 | |
initialDelaySeconds: 10 | |
periodSeconds: 60 | |
readinessProbe: | |
failureThreshold: 2 | |
httpGet: |
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
affinity: | |
podAntiAffinity: | |
requiredDuringSchedulingIgnoredDuringExecution: | |
- labelSelector: | |
matchExpressions: | |
- key: labelKey | |
operator: In | |
values: | |
- labelValue | |
topologyKey: kubernetes.io/hostname |
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
replicas: 2 | |
minReadySeconds: 60 | |
strategy: | |
rollingUpdate: | |
maxSurge: 3 | |
maxUnavailable: 0 | |
type: RollingUpdate |
NewerOlder