-
Notifications
You must be signed in to change notification settings - Fork 26
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
Create custom image that does not have ssh keys stored #343
Changes from 20 commits
d244e71
f6a7af3
673bfaa
06cc3e5
3b1268a
d75af43
8f3a55b
1031a54
7ac173d
a2de733
3837d7c
fe80cd9
7f6ac31
912689d
6213277
589cca9
647f99d
8893d46
de6812f
89e91cb
f5de4f4
73928ab
ca59dc0
b212c85
d992c01
196a1cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Changed | ||
body: Remove keys from the vertica-k8s container. This will be available in the first | ||
server version after 12.0.4. | ||
time: 2023-03-02T08:41:51.161372267-04:00 | ||
custom: | ||
Issue: "343" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,11 +6,13 @@ | |||||
ARG BASE_OS_VERSION="focal-20220801" | ||||||
ARG BUILDER_OS_VERSION="7.9.2009" | ||||||
ARG MINIMAL="" | ||||||
ARG NO_SSH_KEYS="" | ||||||
ARG S6_OVERLAY_VERSION=3.1.2.1 | ||||||
FROM centos:centos${BUILDER_OS_VERSION} as builder | ||||||
|
||||||
ARG VERTICA_RPM="vertica-x86_64.RHEL6.latest.rpm" | ||||||
ARG MINIMAL | ||||||
ARG NO_SSH_KEYS | ||||||
ARG DBADMIN_GID=5000 | ||||||
ARG DBADMIN_UID=5000 | ||||||
|
||||||
|
@@ -68,15 +70,15 @@ RUN set -x \ | |||||
# versions at once. | ||||||
COPY dbadmin/.ssh /home/dbadmin/.ssh | ||||||
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||||||
RUN set -x \ | ||||||
&& mkdir -p /root/.ssh \ | ||||||
&& cp -r /home/dbadmin/.ssh /root \ | ||||||
&& chmod 700 /root/.ssh \ | ||||||
&& chmod 600 /root/.ssh/* \ | ||||||
&& chmod 700 /home/dbadmin/.ssh \ | ||||||
&& chmod 600 /home/dbadmin/.ssh/* \ | ||||||
&& chown -R dbadmin:verticadba /home/dbadmin/ \ | ||||||
&& chmod go-w /etc/ssh/sshd_config.d/* /etc/ssh/ssh_config.d/* | ||||||
&& chmod go-w /etc/ssh/sshd_config.d/* /etc/ssh/ssh_config.d/* \ | ||||||
&& if [[ ($NO_SSH_KEYS == "YES" || $NO_SSH_KEYS == "yes") ]] ; then \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we simplify this to do a case-insensitive compare?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I can also do the same with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that would be good thanks. |
||||||
rm -rf /home/dbadmin/.ssh/*; \ | ||||||
fi | ||||||
|
||||||
############################################################################################## | ||||||
FROM ubuntu:${BASE_OS_VERSION} | ||||||
|
@@ -92,7 +94,6 @@ ARG S6_OVERLAY_VERSION | |||||
|
||||||
COPY --from=builder /opt/vertica /opt/vertica | ||||||
COPY --from=builder --chown=$DBADMIN_UID:$DBADMIN_GID /home/dbadmin /home/dbadmin | ||||||
COPY --from=builder /root/.ssh /root/.ssh | ||||||
COPY --from=builder /var/spool/cron/ /var/spool/cron/crontabs | ||||||
COPY --from=builder /etc/ssh/sshd_config.d/* /etc/ssh/sshd_config.d/ | ||||||
COPY --from=builder /etc/ssh/ssh_config.d/* /etc/ssh/ssh_config.d/ | ||||||
|
@@ -145,7 +146,6 @@ RUN set -x \ | |||||
# Make the "en_US.UTF-8" locale so vertica will be utf-8 enabled by default | ||||||
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ | ||||||
&& mkdir -p /run/sshd \ | ||||||
&& ssh-keygen -q -A \ | ||||||
&& /usr/sbin/groupadd -r verticadba --gid ${DBADMIN_GID} \ | ||||||
&& /usr/sbin/useradd -r -m -s /bin/bash -g verticadba --uid ${DBADMIN_UID} dbadmin \ | ||||||
# Allow passwordless sudo access from dbadmin | ||||||
|
@@ -160,7 +160,9 @@ RUN set -x \ | |||||
&& chmod u+s /usr/sbin/cron \ | ||||||
# Untar the init program that was downloaded earlier | ||||||
&& tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz \ | ||||||
&& tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz | ||||||
&& tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ | ||||||
# delete old host keys | ||||||
&& rm -rf /etc/ssh/ssh_host* | ||||||
spilchen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
ENTRYPOINT [ "/init" ] | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
# | ||
# wander around in the image looking for things you can remove | ||
rm -r -f \ | ||
/opt/vertica/config/* \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be problematic for vertica-demo. They use the vertica-k8s image, and probably rely on the config directory to be set up. Can we change this to remove specific things in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I will delete specific keys files. |
||
/opt/vertica/examples \ | ||
/opt/vertica/packages/*/examples \ | ||
/opt/vertica/oss/python*/lib/python*/test \ | ||
|
@@ -31,7 +32,9 @@ rm -r -f \ | |
/opt/vertica/oss/python*/lib/python*/site-packages/pip \ | ||
/opt/vertica/oss/python*/lib/python*/config-[0-9]* \ | ||
/opt/vertica/oss/python*/lib/python*/tkinter \ | ||
/opt/vertica/oss/python*/lib/python*/idlelib | ||
/opt/vertica/oss/python*/lib/python*/idlelib \ | ||
/opt/vertica/oss/python*/lib/python*/site-packages/Cryptodome/SelfTest/PublicKey/test_vectors/ECC \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a general fix, could we remove all test directories for packages under site-package? We can match |
||
/opt/vertica/oss/python*/lib/python*/site-packages/future/backports/test | ||
|
||
# cleanup many of the __pycache__ directories | ||
find /opt/vertica/oss/ -type d -name "__pycache__" -exec rm -rf {} + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
#!/command/execlineb -P | ||
sudo /usr/sbin/sshd | ||
foreground { sudo ssh-keygen -q -A } sudo /usr/sbin/sshd | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# (c) Copyright [2021-2022] Micro Focus or one of its affiliates. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: "mkdir -p ssh-keys && rm -f ssh-keys/* && ssh-keygen -q -t rsa -N '' -f ssh-keys/id_rsa && cp ssh-keys/id_rsa.pub ssh-keys/authorized_keys" | ||
- script: "kubectl delete secret -n $NAMESPACE ssh-keys || :" | ||
- script: "kubectl create secret -n $NAMESPACE generic ssh-keys --from-file=ssh-keys" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# (c) Copyright [2021-2022] Micro Focus or one of its affiliates. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: "mkdir -p ssh-keys && rm -f ssh-keys/* && ssh-keygen -q -t rsa -N '' -f ssh-keys/id_rsa && cp ssh-keys/id_rsa.pub ssh-keys/authorized_keys" | ||
- script: "kubectl delete secret -n $NAMESPACE ssh-keys || :" | ||
- script: "kubectl create secret -n $NAMESPACE generic ssh-keys --from-file=ssh-keys" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# (c) Copyright [2021-2022] Micro Focus or one of its affiliates. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: "mkdir -p ssh-keys && rm -f ssh-keys/* && ssh-keygen -q -t rsa -N '' -f ssh-keys/id_rsa && cp ssh-keys/id_rsa.pub ssh-keys/authorized_keys" | ||
- script: "kubectl delete secret -n $NAMESPACE ssh-keys || :" | ||
- script: "kubectl create secret -n $NAMESPACE generic ssh-keys --from-file=ssh-keys" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# (c) Copyright [2021-2022] Micro Focus or one of its affiliates. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: "mkdir -p ssh-keys && rm -f ssh-keys/* && ssh-keygen -q -t rsa -N '' -f ssh-keys/id_rsa && cp ssh-keys/id_rsa.pub ssh-keys/authorized_keys" | ||
- script: "kubectl delete secret -n $NAMESPACE ssh-keys || :" | ||
- script: "kubectl create secret -n $NAMESPACE generic ssh-keys --from-file=ssh-keys" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update this comment to explain what we are doing with NO_SSH_KEYS.