'Kuberneted configuration - container has no resource requests for deployment
I'm struggling with Kubernetes configuration in GitLab.
I'm working on project that someone configured like year ago, project has backend and frontend part and I wanted to update password in application configuration. Unfortunately after deploying using GitLab configuration that previous developer left it seems like new version of code was not deployed and application is still using old password. Tried to make some additional changes in code like adding new table through liquibase and this problem still occurred, no table was created after deploying.
I've decided to delete all objects in dev namespace and redeploy application, it worked for backend part, pod, service, deployment.apps for backend were created but while I'm trying to deploy frontend part I'm getting following error
secret/regcred-dashboard unchanged
service/IE599-dashboard created
ingress.extensions/IE599-dashboard configured
Error from server ([denied by k8sresourcesrequestandatory] container <IE599-dashboard> has no resource requests for deployment <IE599-dashboard>): error when creating "STDIN": admission webhook "validation.gatekeeper.sh" denied the request: [denied by k8sresourcesrequestandatory] container <IE599-dashboard> has no resource requests for deployment <IE599-dashboard>
Unfortunately I don't have any experience with Kubernetes and I don't know what's wrong now.
Using following GitLab configuration
deploy to dev:
extends:
- .deployment
- .dev
stage: dev
before_script:
- export CI_ENV=dev
when: manual
.deployment:
dependencies:
- containerize
extends:
- .k8s
script:
- envsubst < ./kubernetes/${CI_ENV}/deployment.yaml | kubectl apply -n IE599-${CI_ENV} -f -
apiVersion: v1
kind: Secret
metadata:
name: regcred-dashboard
namespace: IE599-dev
data:
.dockerconfigjson:
type: kubernetes.io/dockerconfigjson
---
apiVersion: v1
kind: Service
metadata:
name: IE599-dashboard
namespace: IE599-dev
spec:
ports:
- port: 8080
selector:
app: IE599-dashboard
type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: IE599-dashboard
namespace: IE599-dev
labels:
app: IE599-dashboard
service: IE599-dashboard
spec:
rules:
- host: IE599-dev.app.com
http:
paths:
- backend:
serviceName: IE599-dashboard
servicePort: 8080
path: /
tls:
- hosts:
- IE599-dev.app.com
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: IE599-dashboard
namespace: IE599-dev
labels:
app: IE599-dashboard
spec:
replicas: 1
selector:
matchLabels:
app: IE599-dashboard
template:
metadata:
labels:
app: IE599-dashboard
spec:
containers:
- env:
- name: API_URL
value: https://IE599-api-dev.app.com/api
name: IE599-dashboard
image: registry.app.com/IE599/IE599-dashboard:$CI_COMMIT_SHORT_SHA
imagePullPolicy: Always
resources:
limits:
cpu: '100m'
memory: 256Mi
securityContext:
runAsNonRoot: true
runAsUser: 1000
imagePullSecrets:
- name: regcred-dashboard
Not sure why it's not working, I'll appreciate any help here.
Solution 1:[1]
In your deployment you have
resources:
limits:
cpu: '100m'
memory: 256Mi
Update that to:
resources:
limits:
cpu: '100m'
memory: 256Mi
requests:
cpu: '50m'
memory: 200Mi
The error you're getting (has no resource requests for deployment <IE599-dashboard>) is k8's telling you that that you dont have resource requests in your deployment.
Solution 2:[2]
arr = [1, 9, 3, 0, 18, 5, 2, 4, 10, 7, 12, 6]
len1 = len(arr)
long_band = list()
chain = list()
def band(i):
chain.append(i)
j = i+1
if j in arr:
band(j)
else:
long_band.append(chain[:])
del chain[:]
def isHead(n):
x = n-1
if x in arr:
None
else:
band(n)
def FindMaxLen(long_band):
maxLength = max(len(x) for x in long_band)
print(maxLength)
for i in range(len1):
isHead(arr[i])
print(long_band)
FindMaxLen(long_band)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | testfile |
| Solution 2 | lahari chandu |
