Skip to content
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

M1 mac compatibility #5511

Merged
merged 6 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ kafka_connect_string: "{% set ret = [] %}\
kafka_protocol_for_setup: "{{ kafka_protocol | default('PLAINTEXT') }}"

zookeeper:
version: 3.4
image:
amd64: zookeeper:3.4
arm64: arm64v8/zookeeper:3.4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added another zookeeper image for arm64

port: 2181

zookeeper_connect_string: "{% set ret = [] %}\
Expand Down Expand Up @@ -464,7 +466,7 @@ zeroDowntimeDeployment:
enabled: "{{ zerodowntime_deployment_switch | default(false) }}"

etcd:
version: "{{ etcd_version | default('v3.4.33') }}"
version: "{{ etcd_version | default('3.5') }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etcd supports multiarch since 3.5 version.
https://hub.docker.com/r/bitnami/etcd/

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is stale now, but does etcd still require one to enable experimental features to run on arm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore that, I found the answer. Looks like arm64 has first-class support now as of 3.5. Previously it required one to use the ETCD_UNSUPPORTED_ARCH environment variable.

client:
port: 2379
server:
Expand Down
17 changes: 3 additions & 14 deletions ansible/roles/etcd/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,13 @@
- name: (re)start etcd
docker_container:
name: etcd{{ groups['etcd'].index(inventory_hostname) }}
image: quay.io/coreos/etcd:{{ etcd.version }}
image: bitnami/etcd:{{ etcd.version }}
state: started
recreate: true
restart_policy: "{{ docker.restart.policy }}"
volumes: "{{volume_dir | default([])}}"
command: "/usr/local/bin/etcd \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging, I will check how to enable these options with the Bitnami/etcd image.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be addressed in a subsequent PR.

--data-dir=/etcd-data --name '{{ name }}' \
--initial-advertise-peer-urls http://{{ ansible_host }}:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }} \
--advertise-client-urls http://{{ ansible_host }}:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }} \
--listen-peer-urls http://0.0.0.0:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }} \
--listen-client-urls http://0.0.0.0:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }} \
--initial-cluster {{ cluster }} \
--initial-cluster-state new --initial-cluster-token {{ etcd.cluster.token }} \
--quota-backend-bytes {{ etcd.quota_backend_bytes }} \
--snapshot-count {{ etcd.snapshot_count }} \
--auto-compaction-retention {{ etcd.auto_compaction_retention }} \
--auto-compaction-mode {{ etcd.auto_compaction_mode }} \
--log-level {{ etcd.loglevel }}"
env:
"ALLOW_NONE_AUTHENTICATION": "yes"
ports:
- "{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }}:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }}"
- "{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }}:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }}"
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/invoker/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
when: environmentInformation.type == "docker-machine"

- name: "determine docker root dir"
shell: echo -e "GET http:/v1.24/info HTTP/1.0\r\n" | nc -U /var/run/docker.sock | grep "{"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work with the recent version of docker for mac.

shell: docker info -f json
args:
executable: /bin/bash
register: dockerInfo_output
Expand Down
12 changes: 11 additions & 1 deletion ansible/roles/zookeeper/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
---
# This role will install Kafka with Zookeeper in group 'kafka' in the environment inventory

- name: set zookeeper image
set_fact:
zookeeper_image: "{{ zookeeper.image.arm64 }}"
when: ansible_facts['os_family'] == "Darwin" and ansible_facts['architecture'] == "arm64"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selectively use the arm64 zookeeper image according to the os and architecture.


- name: set zookeeper image
set_fact:
zookeeper_image: "{{ zookeeper.image.amd64 }}"
when: ansible_facts['os_family'] != "Darwin" or ansible_facts['architecture'] != "arm64"

- name: (re)start zookeeper
docker_container:
name: zookeeper{{ groups['zookeepers'].index(inventory_hostname) }}
image: zookeeper:{{ zookeeper.version }}
image: "{{ zookeeper_image }}"
state: started
recreate: true
restart_policy: "{{ docker.restart.policy }}"
Expand Down
34 changes: 34 additions & 0 deletions common/scala/Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
# if you change version of openjsk, also update tools/github/setup.sh to download the corresponding jdk
FROM arm64v8/eclipse-temurin:21.0.4_7-jdk-alpine
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the base image is changed.


ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Switch to the HTTPS endpoint for the apk repositories as per https://github.com/gliderlabs/docker-alpine/issues/184
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
RUN apk add --update sed curl bash && apk update && apk upgrade

RUN mkdir /logs

COPY transformEnvironment.sh /
RUN chmod +x transformEnvironment.sh

COPY copyJMXFiles.sh /
RUN chmod +x copyJMXFiles.sh
3 changes: 3 additions & 0 deletions common/scala/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ plugins {
}

ext.dockerImageName = 'scala'
if(System.getProperty("os.arch").toLowerCase(Locale.ENGLISH).startsWith("aarch")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the architecture of OS is m1 Mac, it uses the Dockerfile with the .arm suffix.

ext.dockerDockerfileSuffix = ".arm"
}
apply from: '../../gradle/docker.gradle'

project.archivesBaseName = "openwhisk-common"
Expand Down
10 changes: 10 additions & 0 deletions core/scheduler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ buildscript {
}
}

protobuf {
protoc {
if (osdetector.os == "osx") {
artifact = 'com.google.protobuf:protoc:3.4.0:osx-x86_64'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we cant' upgrade the protoc version for now because some libraries are dependent on this version.
And protoc-3.4.0 does not support arm architecture yet, so I chose this way.
This also requires rosetta installed.

grpc/grpc-java#7690 (comment)

} else {
artifact = 'com.google.protobuf:protoc:3.4.0'
}
}
}

// Define a separate configuration for managing the dependency on Jetty ALPN agent.
configurations {
alpnagent
Expand Down
6 changes: 1 addition & 5 deletions gradle/docker.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ext {
dockerRetries = project.hasProperty('dockerRetries') ? dockerRetries.toInteger() : 3
dockerBinary = project.hasProperty('dockerBinary') ? [dockerBinary] : ['docker']
dockerBuildArg = ['build']
dockerDockerfileSuffix = ""
dockerDockerfileSuffix = project.hasProperty('dockerDockerfileSuffix') ? dockerDockerfileSuffix : ""
}
ext.dockerTaggedImageName = dockerRegistry + dockerImagePrefix + '/' + dockerImageName + ':' + dockerImageTag

Expand All @@ -60,10 +60,6 @@ if(project.hasProperty('dockerBuildArgs')) {
}
}

if(project.hasProperty('dockerfileSuffix')) {
dockerDockerfileSuffix = project.dockerfileSuffix
}

task distDocker {
doLast {
def start = new Date()
Expand Down
80 changes: 80 additions & 0 deletions tools/ow-utils/Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

FROM arm64v8/eclipse-temurin:8u422-b05-jdk-noble
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only changed the base image from adoptopenjdk/openjdk8:jdk8u262-b10 to arm64v8/eclipse-temurin:8u422-b05-jdk-noble.

I used it as the current image is deprecated.

image

https://hub.docker.com/_/adoptopenjdk


ENV DOCKER_VERSION 1.12.0
ENV KUBECTL_VERSION v1.16.3
ENV WHISK_CLI_VERSION latest
ENV WHISKDEPLOY_CLI_VERSION latest

RUN apt-get update && apt-get install -y \
git \
jq \
libffi-dev \
nodejs \
npm \
python-is-python3 \
python3-pip \
python3-venv \
wget \
zip \
locales \
&& rm -rf /var/lib/apt/lists/*

# update npm
RUN npm install -g n && n stable && hash -r

RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

WORKDIR /root

RUN python -m venv .venv
ENV PATH="/root/.venv/bin:$PATH"

# Python packages
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools
RUN pip3 install cryptography && \
pip3 install ansible==2.5.2 && \
pip3 install jinja2==2.9.6 && \
pip3 install docker

# Install docker client
RUN wget --no-verbose https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz && \
tar --strip-components 1 -xvzf docker-${DOCKER_VERSION}.tgz -C /usr/bin docker/docker && \
rm -f docker-${DOCKER_VERSION}.tgz && \
chmod +x /usr/bin/docker

# Install kubectl in /usr/local/bin
RUN curl -Lo ./kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/kubectl

# Install `wsk` cli in /usr/local/bin
RUN wget -q https://github.com/apache/openwhisk-cli/releases/download/$WHISK_CLI_VERSION/OpenWhisk_CLI-$WHISK_CLI_VERSION-linux-amd64.tgz && \
tar xzf OpenWhisk_CLI-$WHISK_CLI_VERSION-linux-amd64.tgz -C /usr/local/bin wsk && \
rm OpenWhisk_CLI-$WHISK_CLI_VERSION-linux-amd64.tgz

# Install wskadmin in /bin
COPY wskutil.py /bin
COPY wskprop.py /bin
COPY wskadmin /bin

# Setup tools/data for certificate generation (used by openwhisk-deploy-kube)
RUN mkdir /cert-gen
COPY openwhisk-server-key.pem /cert-gen
COPY genssl.sh /usr/local/bin/
3 changes: 3 additions & 0 deletions tools/ow-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/

ext.dockerImageName = 'ow-utils'
if(System.getProperty("os.arch").toLowerCase(Locale.ENGLISH).startsWith("aarch64")) {
ext.dockerDockerfileSuffix = ".arm"
}
apply from: '../../gradle/docker.gradle'

distDocker.dependsOn 'copyWskadmin', 'copyGenssl'
Expand Down
Loading