Kodekloud Challenge #1 issue with creating the pod - issue with command

Hi - this is very confusing - it seems that this won’t validate the command that I have in the pod yaml.

Here is my YAML file

`

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: jekyll
  name: jekyll
  namespace: development
spec:
  initContainers:
  - name: copy-jekyll-site
    image: kodekloud/jekyll
    command: 
     -  jekyll
     -  new
     -  /site
    volumeMounts:
     - mountPath: "/site"
       name: site
  containers:
  - image: kodekloud/jekyll-serve
    name: jekyll
    resources: {}
    volumeMounts:
     - mountPath: "/site"
       name: site
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
   - name: site
     persistentVolumeClaim:
       claimName: jekyll-site
status: {}

`

Here is the pod status:

Name:         jekyll
Namespace:    development
Priority:     0
Node:         <none>
Labels:       run=jekyll
Annotations:  <none>
Status:       Pending
IP:           
IPs:          <none>
Init Containers:
  copy-jekyll-site:
    Image:      kodekloud/jekyll
    Port:       <none>
    Host Port:  <none>
    Command:
      jekyll
      new
      /site
    Environment:  <none>
    Mounts:
      /site from site (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-8h4pt (ro)
Containers:
  jekyll:
    Image:        kodekloud/jekyll-serve
    Port:         <none>
    Host Port:    <none>
    Environment:  <none>
    Mounts:
      /site from site (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-8h4pt (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  site:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  jekyll-site
    ReadOnly:   false
  kube-api-access-8h4pt:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

Is there something i’m missing? Everything else validates as correct. I spend 30 minutes getting everything else set up and then 30 minutes failing to troubleshoot this issue.

Really strange, but for anyone else encountering this issue - it resolved itself after some time. My guess is that the pending pod just took a while until it finally started up?

2 Likes

Hi @klein.joshua.a

Just ran your YAML through the challenge. It is fine.
Note that the init container may take up to 90 seconds to do its job before the main container starts.

You should wait till the main container is fully running before pressing the check button

kubectl get po -n development                                                              
NAME     READY   STATUS    RESTARTS   AGE
jekyll   1/1     Running   0          3m55s

Error is related to ruby in init container image due to which the pod is not initializing although all the settings are correct in pod yaml.

/usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:91:in `block in materialize’: Could not find public_suffix-4.0.7 in any of the sources (Bundler::GemNotFound)

Possibly the initContainer image needs to be rebuild - bundler is broken in ruby image: /usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException) · Issue #194 · docker-library/ruby · GitHub

Hi @srinivasons

I have just tested that scenario and it is fine. Please post the YAML for your jekyll pod so that we may check it. Please remember to paste yaml within a code block to preserve indentation (use </> button in post editor)

It worked this time although i did nothing different. The init container logs before and now says it all … Thanks anyhow.

root@controlplane ~ ➜ kubectl logs jekyll -c copy-jekyll-site -n development
Running bundle install in /site…
Bundler: The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Bundler: Fetching gem metadata from https://rubygems.org/
Bundler: Fetching gem metadata from https://rubygems.org/.
Bundler: Resolving dependencies…
Bundler: Fetching public_suffix 4.0.7
Bundler: Installing public_suffix 4.0.7
Bundler: Fetching addressable 2.8.0
Bundler: Installing addressable 2.8.0
Bundler: Using bundler 1.17.3
Bundler: Using colorator 1.1.0
Bundler: Fetching concurrent-ruby 1.1.10
Bundler: Installing concurrent-ruby 1.1.10
Bundler: Using eventmachine 1.2.7
Bundler: Fetching http_parser.rb 0.8.0
Bundler: Installing http_parser.rb 0.8.0 with native extensions
Bundler: Fetching em-websocket 0.5.3
Bundler: Installing em-websocket 0.5.3
Bundler: Fetching ffi 1.15.5
Bundler: Installing ffi 1.15.5 with native extensions
Bundler: Using forwardable-extended 2.6.0
Bundler: Using i18n 0.9.5
Bundler: Fetching rb-fsevent 0.11.1
Bundler: Installing rb-fsevent 0.11.1
Bundler: Fetching rb-inotify 0.10.1
Bundler: Installing rb-inotify 0.10.1
Bundler: Using sass-listen 4.0.0
Bundler: Using sass 3.7.4
Bundler: Using jekyll-sass-converter 1.5.2
Bundler: Fetching listen 3.7.1
Bundler: Installing listen 3.7.1
Bundler: Using jekyll-watch 2.2.1
Bundler: Using kramdown 1.17.0
Bundler: Using liquid 4.0.3
Bundler: Using mercenary 0.3.6
Bundler: Using pathutil 0.16.2
Bundler: Fetching rouge 3.29.0
Bundler: Installing rouge 3.29.0
Bundler: Using safe_yaml 1.0.5
Bundler: Fetching jekyll 3.8.7
Bundler: Installing jekyll 3.8.7
Bundler: Fetching jekyll-feed 0.16.0
Bundler: Installing jekyll-feed 0.16.0
Bundler: Fetching jekyll-seo-tag 2.8.0
Bundler: Installing jekyll-seo-tag 2.8.0
Bundler: Fetching minima 2.5.1
Bundler: Installing minima 2.5.1
Bundler: Bundle complete! 4 Gemfile dependencies, 28 gems now installed.
Bundler: Bundled gems are installed into /usr/local/bundle
New jekyll site installed in /site.

root@controlplane ~ ➜ kubectl get po -n development
NAME READY STATUS RESTARTS AGE
jekyll 1/1 Running 0 61s

You’re welcome.
Sometimes the labs just need a reset.
Best to check if a problem is repeatable - that’s the DevOps way anyhow :smiley:

1 Like

Same issue all steps completed for CKS challenge 1. Only issue is command to run: jekyll new /site

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: jekyll
  name: jekyll
  namespace: development
spec:
  volumes:
    - name: site
      persistentVolumeClaim:
        claimName: jekyll-site
  initContainers:
  - name: copy-jekyll-site
    image: kodekloud/jekyll
    command: ['sh', '-c', 'jekyll', 'new', '/site' ]
	volumeMounts:
    - name: site
      mountPath: /site
  containers:
  - image: kodekloud/jekyll-serve
    name: jekyll
	volumeMounts:
    - name: site
      mountPath: /site
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always

I used the pod definition given at https://github.com/kodekloudhub/kubernetes-challenges/blob/master/challenge-1/jekyll-pod.yaml and it gives me the error for the command !

Hi @stephane.hordoir

It works fine. I just tested it. Please work through the solution as given on the github site.

oh thanks i will recheck !

Hi! I just arrived to this post after getting the same error. These are the logs on the container:

kubectl logs jekyll -n development copy-jekyll-site
/usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:91:in `block in materialize': Could not find public_suffix-4.0.7 in any of the sources (Bundler::GemNotFound)
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `map!'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `materialize'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:170:in `specs'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:237:in `specs_for'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:226:in `requested_specs'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:108:in `block in definition_method'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:20:in `setup'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:107:in `setup'
        from /usr/local/bundle/gems/jekyll-3.8.5/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
        from /usr/local/bundle/gems/jekyll-3.8.5/exe/jekyll:11:in `<top (required)>'
        from /usr/local/bundle/bin/jekyll:23:in `load'
        from /usr/local/bundle/bin/jekyll:23:in `<main>'

And this is my pod definition yaml:


root@controlplane ~ ➜  cat pod.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: jekyll
  namespace: development
  labels:
    run: jekyll
spec:
  initContainers:
  - name: copy-jekyll-site 
    image: kodekloud/jekyll
    command: [ "jekyll", "new", "/site"]
    volumeMounts:
    - name: site
      mountPath: /site
  containers:
  - name: jekyll
    image: kodekloud/jekyll-serve
    volumeMounts:
    - name: site
      mountPath: /site
  volumes:
  - name: site
    persistentVolumeClaim:
      claimName: jekyll-site

I tried it several times, even restarting the environment.
I will be just skipping this part since I understand it is not an error on the problem proposed.

Hi @danih

I just ran the lab again and guess what? No issues.

Try doing it directly from the solution in github (https://github.com/kodekloudhub/kubernetes-challenges/tree/master/challenge-1):

    git clone --depth 1 https://github.com/kodekloudhub/kubernetes-challenges.git

    ### PVC
    kubectl apply -f kubernetes-challenges/challenge-1/jekyll-pvc.yaml

    ### POD
    kubectl apply -f kubernetes-challenges/challenge-1/jekyll-pod.yaml

And then check the pod logs

Hi!
The pod fails at startup using the yaml file from https://github.com/kodekloudhub/kubernetes-challenges/tree/master/challenge-1:

/usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:91:in `block in materialize': Could not find public_suffix-4.0.7 in any of the sources (Bundler::GemNotFound)
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `map!'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `materialize'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:170:in `specs'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:237:in `specs_for'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:226:in `requested_specs'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:108:in `block in definition_method'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:20:in `setup'
        from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:107:in `setup'
        from /usr/local/bundle/gems/jekyll-3.8.5/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
        from /usr/local/bundle/gems/jekyll-3.8.5/exe/jekyll:11:in `<top (required)>'
        from /usr/local/bundle/bin/jekyll:23:in `load'
        from /usr/local/bundle/bin/jekyll:23:in `<main>'

Hello arisnegro,

Can you try it again with the steps in the attached gif
Challenge1
?

Hi,
After 4 times trying to finish this challenge and always failing on the above bug, I found out that the pvc binding is always failing for me (even if it is shown green) when the storageClassName is not set to local-storage.

This information is missing above and on the GitHub repository.

1 Like

Hello @Sebastian-Fischer,
Thanks for highlighting this to us
I will forward your request to the KK team.

I ran into the same issue today. I tried to delete the pvc and pod and use the solution files from GitHub but then the pv got deleted. Frustrating. Thank you for looking into this, these challenges are great to practise on!

Hi @boy1,

Just testing the lab and it works fine. Can you please try again and follow the instructions step by step?

Bonjour @mmkmou !

Merci for testing.
I tried the lab twice more (once I accidentally got the pvc incorrect and couldn’t delete the pv so got stuck again). The third time was the charm because by then I could do it flawlessly. It seems to work unless you have to try multiple times because, you know, you’re still learning…
Maybe it happens when you delete and recreate the pod and run the command twice?
Anyway, for others trying this out, it’s probably best to stop trying and just reset the environment once you mess up the pvc or you see that ruby error.

Cheers,
Boy