Hi @Ayman,
I have just completed the task Deploy Iron Gallery App on Kubernetes
. It has been marked as failed, even though I believe that I have correctly carried out the task.
This is the error returned:
template's spec env 'MYSQL_DATABASE' value is not 'database_host' under namespace 'iron-namespace-nautilus'
I have created the correct value for MYSQL_DATABASE
, so I am not sure what the real error is, if any at all.
Could someone look into this for me to see if there is a possible validation error?
I have marked it for review, but so far it ‘looks’ like I may have completed the task correctly…nor entirely sure of course.
Thanks in advance:-)
hi @juliettet, can you please share your yml template ?
1 Like
Hi @rahul456,
Thank you for responding. This is how I created my secret:
kb create secret generic mysecret -n iron-namespace-nautilus --from-literal=MYSQL_DATABASE=database_host --from-literal=MYSQL_ROOT_PASSWORD=MYSQL_PASSWORD --from-literal=MYSQL_USER=customuser
Here is my iron-db-deployment-nautilus
template:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
db: mariadb
name: iron-db-deployment-nautilus
namespace: iron-namespace-nautilus
spec:
replicas: 1
selector:
matchLabels:
db: mariadb
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
db: mariadb
spec:
volumes:
- name: db
emptyDir: {}
containers:
- image: kodekloud/irondb:2.0
name: iron-db-container-nautilus
envFrom:
- secretRef:
name: mysecret
volumeMounts:
- name: db
mountPath: /var/lib/mysql
resources: {}
status: {}
Thanks again!
HI @juliettet
What i can see is that you are using imperative and declarative both . If you have already defined secrets using kubectl no need for passing secretRef in yaml file as it is looking for a definition file of secret mysecret and not able to find .
If you are specifying secretRef you need to create a secret-data.yml file too.
1 Like
Hello, @juliettet
I think you have to specify in this way:
containers:
- name: mycontainer
image: redis
env:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: mysecret
key: username
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: password
For more clarifications. Please read from here.
1 Like
hi @juliettet, sorry for the issue, this is marked pending for you, please give it an another try.
1 Like
Thank you @sadiq1425! I will try to complete this task with a secret-data.yml
like you have suggested.
Thank you @Tej-Singh-Rana! I will look into this approach and try it out as well & thank you for the link:-)
Thank you for looking into this for me @rahul456!
Hello @Tej-Singh-Rana, @sadiq1425 , & @rahul456,
I have just completed the task. This is what I ended up going with:
kb create secret generic mysecret -n iron-namespace-devops \
--from-literal=MYSQL_DATABASE=database_web \
--from-literal=MYSQL_ROOT_PASSWORD='rootpasswd' \
--from-literal=MYSQL_PASSWORD='sqlpasswd' \
--from-literal=MYSQL_USER=customuser -o yaml --dry-run=client > mix-sec.yaml
kbc mix-sec.yaml
env:
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: mysecret
key: MYSQL_DATABASE
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: mysecret
key: MYSQL_USER
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: MYSQL_PASSWORD
Thanks again to everyone!!
1 Like
Does it resolve your issue ?
Hi @sadiq1425,
It’s difficult to say because it looks like there was more than one way to complete this task + it appears that there was a validation error(?) initially. Of all of the methods that I tried I got the same result. The task was reset for me, so I did not get the chance to check your (or Mando’s) suggestions as a solution. I would give you (and Mando) the points for helping out if I could.
Thanks for taking the time to look into this with me!!
1 Like