-
Notifications
You must be signed in to change notification settings - Fork 1.5k
scripts for nested-libvirt ci #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
sallyom:danmace-libvirt-scripts
Nov 14, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # This Dockerfile is a used by CI to test a libvirt cluster launched in a gce instance | ||
| # It builds an image containing google-cloud-sdk, ns_wrapper and scripts to launch a VM for a libvirt install. | ||
| FROM openshift/origin-release:golang-1.10 AS build | ||
| WORKDIR /go/src/github.com/openshift/installer | ||
| COPY . . | ||
| RUN hack/build.sh && hack/get-terraform.sh | ||
|
|
||
| FROM centos:7 | ||
| COPY --from=build /go/src/github.com/openshift/installer/bin/openshift-install /bin/openshift-install | ||
| COPY --from=build /go/src/github.com/openshift/installer/bin/terraform /bin/terraform | ||
| COPY --from=build /go/src/github.com/openshift/installer/images/nested-libvirt/google-cloud-sdk.repo /etc/yum.repos.d/google-cloud-sdk.repo | ||
| COPY --from=build /go/src/github.com/openshift/installer/images/nested-libvirt/mock-nss.sh /bin/mock-nss.sh | ||
|
|
||
| RUN yum install -y \ | ||
| epel-release \ | ||
| gettext \ | ||
| google-cloud-sdk \ | ||
| openssh-clients && \ | ||
| yum --enablerepo=epel-testing install -y nss_wrapper && \ | ||
| yum -y update && \ | ||
| yum clean all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Nested libvirt on GCE | ||
|
|
||
| This image enables launching a libvirt cluster nested in a GCE instance, for libvirt CI testing. | ||
|
|
||
| This image contains [`nss_wrapper`](https://cwrap.org/nss_wrapper.html) to execute `ssh` commands as | ||
| a mock user to interact with a GCE instance from an OpenShift container. | ||
|
|
||
| OpenShift containers run with an arbitrary uid, but SSH requires a valid user. `nss_wrapper` | ||
| allows for the container's user ID to be mapped to a username inside of a container. | ||
|
|
||
| ### Example Usage | ||
|
|
||
| You can override the container's current user ID and group ID by providing `NSS_WRAPPER_GROUP` | ||
| and `NSS_WRAPPER_PASSWD` for the mock files, as well as `NSS_USERNAME`, `NSS_UID`, `NSS_GROUPNAME`, | ||
| and/or `NSS_GID`. In OpenShift CI, `NSS_USERNAME` and `NSS_GROUPNAME` are set. | ||
| The random UID assigned to the container is the UID that the mock username is mapped to. | ||
|
|
||
| ```console | ||
| $ podman run --rm \ | ||
| > -e NSS_WRAPPER_GROUP=/tmp/group \ | ||
| > -e NSS_WRAPPER_PASSWD=/tmp/passwd \ | ||
| > -e NSS_UID=1000 \ | ||
| > -e NSS_GID=1000 \ | ||
| > -e NSS_USERNAME=testuser \ | ||
| > -e NSS_GROUPNAME=testuser \ | ||
| > nss_wrapper_img mock-nss.sh id testuser | ||
| uid=1000(testuser) gid=1000(testuser) groups=1000(testuser) | ||
| ``` | ||
|
|
||
| Or, in an OpenShift container: | ||
|
|
||
| ```yaml | ||
| containers: | ||
| - name: setup | ||
| image: nss-wrapper-image | ||
| env: | ||
| - name: NSS_WRAPPER_PASSWD | ||
| value: /tmp/passwd | ||
| - name: NSS_WRAPPER_GROUP | ||
| value: /tmp/group | ||
| - name: NSS_USERNAME | ||
| value: mockuser | ||
| - name: NSS_GROUPNAME | ||
| value: mockuser | ||
| command: | ||
| - /bin/sh | ||
| - -c | ||
| - | | ||
| #!/bin/sh | ||
| mock-nss.sh | ||
| LD_PRELOAD=/usr/lib64/libnss_wrapper.so gcloud compute scp [gcloud scp args] | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [google-cloud-sdk] | ||
| name=Google Cloud SDK | ||
| baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 | ||
| enabled=1 | ||
| gpgcheck=1 | ||
| repo_gpgcheck=1 | ||
| gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg | ||
| https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/bash | ||
|
|
||
| # mock passwd and group files | ||
| ( | ||
| exec 2>/dev/null | ||
| username="${NSS_USERNAME:-$(id -un)}" | ||
| uid="${NSS_UID:-$(id -u)}" | ||
|
|
||
| groupname="${NSS_GROUPNAME:-$(id -gn)}" | ||
| gid="${NSS_GID:-$(id -g)}" | ||
|
|
||
| echo "${username}:x:${uid}:${uid}:gecos:${HOME}:/bin/bash" > "${NSS_WRAPPER_PASSWD}" | ||
| echo "${groupname}:x:${gid}:" > "${NSS_WRAPPER_GROUP}" | ||
| ) | ||
|
|
||
| # wrap command | ||
| export LD_PRELOAD=/usr/lib64/libnss_wrapper.so | ||
| exec "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.