Sasha Polakow-Suransky, in his book The Unspoken Alliance: Israel's Secret Relationship with Apartheid South Africa (2010), details Israel's longstanding and extensive military links with apartheid South Africa, links that apparently included work on nuclear weapons and missiles that could carry them.
The driving force behind the establishment of these ties, from Israel's perspective, was realpolitik rather than ideology. Shimon Peres played a significant role in establishing the program in its early years, when the Labor party ruled Israel. He "routinely denounced apartheid in public," Polakow-Suransky writes, and I assume those statements were sincere. But after a visit to South Africa in 1974, he wrote to the South African leaders he'd met with that "'this cooperation is based not only on common interest and on the determination to resist equally our enemies, but also on the unshakeable foundations of our common hatred of injustice and our refusal to submit to it.'" (Chapter 5, text preceding note 27, Kindle location 1639 of 7386).
After 1977, when Menachem Begin and Likud came to power, "the confluence of interests and similar ideologies pushed the two countries into a much more intimate relationship after 1977." Polakow-Suransky does not see the Likud leaders as racist, but he writes that Likud's "ethnonationalist ideology allowed Begin and other Likud leaders to stomach racist apartheid policies because these were part of a larger nationalist project designed to protect a minority group that believed its survival was threatened." (Chapter 6, text following note 25, Kindle location 2256 of 7386)
The result was a program that provided both countries with substantial benefits during years when they had few other allies. But the trouble with realpolitik is that it so often comes back to haunt you. That was certainly the case here. Polakow-Suransky reports that in 1993 a far-left Israeli politician, Elazar Granot, spoke at the Socialist International and "lavished praise on [Nelson] Mandela, comparing him to Moses and arguing that South Africa's president-in-waiting was even greater than Moses for he had actually reached the Promised Land." But, "[a]s Granot recalls it, the first words from South Africa's icon of forgiveness and reconciliation were: 'The people of South Africa will never forget the support of the state of Israel to the apartheid regime.'" (Chapter 12, text at note 19, Kindle location 4517 of 7386).