def create_image_pull_secret():
    """Create certificate for image hub (Once for a system)"""
    image_hub_url = os.environ.get('IMAGE_HUB_URL')
    image_hub_username = os.environ.get('IMAGE_HUB_USERNAME')
    image_hub_password = os.environ.get('IMAGE_HUB_PASSWORD')
    if image_hub_url is None or image_hub_username is None or \
        image_hub_password is None:
        return

    # using base64 to encode authorization information
    encoded_username_password = str(b64encode(
        '{}:{}'.format(image_hub_username, image_hub_password)
    ))
    encoded_image_cert = str(b64encode(
        json.dumps({
            'auths': {
                image_hub_url: {
                    'username': image_hub_username,
                    'password': image_hub_password,
                    'auth': encoded_username_password
                }
            }})), 'utf-8')

    k8s_client.create_or_update_secret(
        data={
            '.dockerconfigjson': encoded_image_cert
        },
        metadata={
            'name': 'regcred',
            'namespace': 'default'
        },
        secret_type='kubernetes.io/dockerconfigjson',
        name='regcred'
    )
Create certificate for image hub (Once for a system)
web_console_v2/api/fedlearner_webconsole/utils/certificate.py