kubernetes icon indicating copy to clipboard operation
kubernetes copied to clipboard

publish an event when the container is restarted

Open Ritikaa96 opened this issue 1 year ago • 7 comments

What type of PR is this?

/kind feature

What this PR does / why we need it:

This adds a container event for container restarts.

Which issue(s) this PR fixes:

Fixes #https://github.com/kubernetes/kubernetes/issues/123176

Does this PR introduce a user-facing change?

Added a new container event for container restart which will be visible in the events section of kubectl describe of pod.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Not needed.

Not needed.

Ritikaa96 avatar Jul 31 '24 03:07 Ritikaa96

An alternative idea for dealing with this is to use the approach used by hugo for diagrams - https://gohugo.io/content-management/diagrams/ along with prism.js. I wanted to add some custom syntax highlighting in a code block - I want the word "when" to be treated as a keyword and for it to be highlighted as well.

Add a custom code block render hook - layouts/_default/_markup/render-codeblock-boc.html

{{- $content := .Inner -}}
<pre class="language-boc">
<code class="language-boc" style="margin: 0; padding: 0;">
    {{- $content | htmlEscape | safeHTML -}}
</code>
</pre>

{{ .Page.Store.Set "hasBoCCode" true }}

Extend prism (more detail on how to do that) by adding support for my custom syntax highlighting by adding the following file at static/js/prism-boc.js

Prism.languages.boc = {
  keyword: /\b(when)\b/,
  // 'function': /\b\w+(?=\()/,
  // 'string': /"(?:\\.|[^\\"])*"/,
  // 'number': /\b\d+\b/,
  // 'comment': /\/\/.*/
};

Updating the baseof template to import the prism scripts

<!--...-->
  <head>
<!--...-->
    {{ if .Store.Get "hasBoCCode" }}
      <link
        rel="stylesheet"
        href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css"
      />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
      <script src="/js/prism-boc.js"></script>
    {{ end }}
<!--...-->

The only drawback of this approach is that this will break highlighting for all other code blocks if the prism scripts are loaded (which for me wasn't an issue but isn't particularly ideal).

Another drawback is that the renderring is happening client side

prnvbn avatar Dec 21 '24 22:12 prnvbn

I'm closing this for now. This ball may be picked up again in the future, but I don't want to add/maintain more complexity to a setup that works great for 99.999% of the use cases.

bep avatar Dec 22 '24 12:12 bep

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jan 13 '25 02:01 github-actions[bot]