Eric Smalling
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # SnykLive: KubeCon 2021 Edition - Oct 14, 2021 ## KubeCon IaC Review Office Hours: Bring your code and questions ### [YouTube Live Stream](https://youtu.be/XRSNvAM2_lY) ### Hosts: * [@bretfisher](https://twitter.com/BretFisher) * [@ericsmalling](https://twitter.com/ericsmalling) ## Agenda: 1. Introduction 2. KubeCon 2021 news 3. IaC Code reviews ### Audience participation If you have a Dockerfile, Kubernetes YAML, Helm chart, etc that you would like discussed, into the following list a brief summary of your request/question and link(s) to the public repo, gist or similar site with the content you are referring to. If your sample code is small, you may in-line it with a markdown code block as shown in the example below. **Please make sure that no credentials or other sensitive data is present in the code shared! (passwords, keys, internal host/ip info, etc)** Please prefix your name/YouTube chat username to your list item so we know who we are addressing. (unless you just want to stay anonymous, I suppose!) #### Post your code reviews / questions here: * *Example 1:* [Eric Smalling] - Deploying the following to my kind cluster shows a `CreateContainerConfigError` and describing shows `Error: container has runAsNonRoot and image has non-numeric user (nobody), cannot verify user is non-root` Why is this? The image is built from this project: https://github.com/kubernetes-up-and-running/kuard ``` yaml apiVersion: v1 kind: Pod metadata: labels: run: kuard name: kuard spec: containers: - image: gcr.io/kuar-demo/kuard-amd64:blue name: kuard securityContext: runAsNonRoot: true restartPolicy: Never ``` * *Example 2:* [Eric Smalling] - My company containerized a JEE app a while ago, how does this Dockerfile look to you? https://github.com/ericsmalling/java-goof/blob/master/Dockerfile *Add your questions below* * Nick R - Here is a basic DockerFile we use. Give me what we are doing wrong. ``` docker # base image FROM node:lts # Install nginx to serve the content RUN apt-get update && \ apt-get -y install nginx \ && apt-get -y install libglu1 # set working directory RUN mkdir /app WORKDIR /app # add `/usr/src/app/node_modules/.bin` to $PATH ENV PATH /app/node_modules/.bin:$PATH ARG DEPLOY_ENV # install and cache app dependencies COPY web/.npmrc /app/.npmrc COPY web/package.json /app/package.json COPY web/package-lock.json /app/package-lock.json COPY start.sh /app/start.sh RUN npm ci COPY web/ /app # copy files for nginx COPY deployments/nginx/nginx.conf /app/nginx/nginx.conf COPY deployments/nginx/mime.types /app/nginx/mime.types # copy cert files RUN mkdir /app/certs COPY deployments/nginx/dev.net.crt /app/certs/cert.crt COPY deployments/nginx/dev.net.rsa /app/certs/cert.rsa # start app EXPOSE 80 443 CMD ["/bin/bash", "start.sh"] ``` * Here is Bret's refactor of that file ```dockerfile # base image, make sure it's pinned to a specific version FROM node:14.15.0 as node # DON'T install nginx. Instead, copy these files to a new nginx stage later RUN apt-get update \ && apt-get install -y --no-install-recommends \ # TODO: add version for libglu1 libglu1 \ # cleanup && rm -rf /var/lib/apt/lists/* # set working directory WORKDIR /app # add `/usr/src/app/node_modules/.bin` to $PATH ENV PATH /app/node_modules/.bin:$PATH # FIXME: don't hardcode environments in the image. # Each environment setting should be set at runtime # ARG DEPLOY_ENV # install and cache app dependencies COPY web/.npmrc /app/.npmrc COPY web/package*.json /app/ # we likely don't need a startup script, and CMD shouldn't use a script IMO # Scipts are likely not to handle kernel signals well # If you need a ENTRYPOINT script, then that's different # COPY start.sh /app/start.sh RUN npm ci COPY web/ /app # TODO build static stuff here, before we copy output to nginx FROM nginx:1.21.3 as nginx # copy files for nginx COPY deployments/nginx/nginx.conf /app/nginx/nginx.conf COPY deployments/nginx/mime.types /app/nginx/mime.types # COPY in source code from previous stage COPY --from=node /app/ /app/ # TODO: make a different image for proxy and tls like traefik or nginx # don't combine web server with proxy config in distributed computing # ideally you want to control and scale your backend, frontend, and proxy separately # nginx config already EXPOSES 80 I think, so no need to repeat this # EXPOSE 80 443 ``` ### Show Notes: ### Links: #### Favorite KubeCon Sessions **Day 1:** * **Back to the Drawing Board: Building Containers with SBoMs** - Nisha Kumar, VMware * **Kubernetes Supply Chain Security: The Software Factory** - Andrew Martin, Control Plane * **sigstore: How We Started, Where We Are, Where We are Headed** - Bob Callaway, Red Hat & Dan Lorenc, Google * **Kubernetes Exposed! Seven of Nine Hidden Secrets That Will Give You Pause** - Ian Coldwater, Twilio & Brad Geesaman, Aqua Security * **Exploiting a Slightly Peculiar Volume Configuration with SIG-Honk** - Ian Coldwater, Twilio; Brad Geesaman & Rory McCune, Aqua Security; Duffie Cooley, * **My Container Image has 500 Vulnerabilities, Now What?** - Matt Jarvis, Snyk #### Useful IaC links #### Comments from the show

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully